(Created page with "=Attributes= {{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 "..r...") |
|||
Line 4: | Line 4: | ||
local ray=Space.Camera.ScreenCoordinatesToRay(Vector.New(0.5,0.5,0))<br> | local ray=Space.Camera.ScreenCoordinatesToRay(Vector.New(0.5,0.5,0))<br> | ||
Space.Log("Origin "..ray.Origin.ToString()) | 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= | {{ScriptFunction|SVector|Direction|;|The direction of the ray.|5= | ||
local ray=Space.Camera.ScreenCoordinatesToRay(Vector.New(0.5,0.5,0))<br> | local ray=Space.Camera.ScreenCoordinatesToRay(Vector.New(0.5,0.5,0))<br> | ||
Space.Log("Direction "..ray.Direction.ToString()) | 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}} | {{Scripting Navbox}} |
The origin point of the ray.
--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)
The direction of the ray.
--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)
|