|
|
Line 1: |
Line 1: |
− | =Attributes=
| + | This page has moved to: https://docs.sine.space/v/scripting/client-scripting/types/sray |
− | | + | |
− | {{ScriptFunction|SVector|Origin|;|The origin point of the ray.|5=
| + | |
− | local ray=Space.Camera.ScreenCoordinatesToRay(Vector.New(0.5,0.5,0))<br>
| + | |
− | Space.Log("Origin "..ray.Origin.ToString())
| + | |
− | |6=<pre> --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) </pre>}}
| + | |
− | | + | |
− | {{ScriptFunction|SVector|Direction|;|The direction of the ray.|5=
| + | |
− | local ray=Space.Camera.ScreenCoordinatesToRay(Vector.New(0.5,0.5,0))<br>
| + | |
− | Space.Log("Direction "..ray.Direction.ToString())
| + | |
− | |6=<pre> --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) </pre>}}
| + | |
− | | + | |
− | {{Scripting Navbox}}
| + | |