Breakroom is now Sinewave Campus. Book a meeting

SRay

ClientTypes
Dans cette classeOrigin
  1. Propriétés
  2. Origin
  3. Direction
Membres 2
PropriétéOriginThe origin point of the ray.
PropriétéDirectionThe direction of the ray.

Propriétés​

OriginLecture seule​

SVector Origin {get; }

The origin point of the ray.

Exemple

Lua
ray=Space.Camera.ScreenCoordinatesToRay(Vector.New(0.5,0.5,0))
rayOrigin = ray.Origin
Lua
--this script will make this object jump to wherever you right click
--(Example: moving objects with right click )

thisGameObject = Space.Host.ExecutingObject


OnUpdate = function()
if Space.Input.GetMouseDown(1) then
clickRay = Space.Camera.ScreenCoordinatesToRay(Space.Input.MousePosition)
rayCastHit = Space.Physics.RayCastSingle(clickRay.Origin, clickRay.Direction, 50.0)
thisGameObject.WorldPosition = rayCastHit.Position
end
end

thisGameObject.SubscribeToEvents()
thisGameObject.OnUpdate(OnUpdate)

DirectionLecture seule​

SVector Direction {get; }

The direction of the ray.

Exemple

Lua
ray=Space.Camera.ScreenCoordinatesToRay(Vector.New(0.5,0.5,0))
rayDirection = ray.Direction
Lua
--this script will make this object jump to wherever you right click
--(Example: moving objects with right click )

thisGameObject = Space.Host.ExecutingObject


OnUpdate = function()
if Space.Input.GetMouseDown(1) then
clickRay = Space.Camera.ScreenCoordinatesToRay(Space.Input.MousePosition)
rayCastHit = Space.Physics.RayCastSingle(clickRay.Origin, clickRay.Direction, 50.0)
thisGameObject.WorldPosition = rayCastHit.Position
end
end

thisGameObject.SubscribeToEvents()
thisGameObject.OnUpdate(OnUpdate)