(Added examples to: IsLocked, ReleaseCamera, LockCamera, SetCameraPositionOrientation) |
(Added ScreenCoordinatesToRay) |
||
Line 29: | Line 29: | ||
local VectorRot = Quaternion.Euler(-60,0,0);<br><br> | local VectorRot = Quaternion.Euler(-60,0,0);<br><br> | ||
Space.Camera.LockCamera (obj);<br> | Space.Camera.LockCamera (obj);<br> | ||
− | Space.Camera.SetCameraPositionOrientation (VectorPos,VectorRot); | + | Space.Camera.SetCameraPositionOrientation (VectorPos,VectorRot);<br> |
− | ''-- Now the camera is positioned at the global origin and is facing the sky at 60 degrees.''<br> | + | ''-- Now the camera is positioned at the global origin and is facing the sky at 60 degrees.'' |
+ | }} | ||
+ | |||
+ | |||
+ | {{ScriptFunction|SRay|ScreenCoordinatesToRay|(SVector screenCoordinates);|Returns a ray going from camera through a screen point.|5= | ||
+ | obj = Space.Host.ExecutingObject;<br> | ||
+ | local cameraRay = Space.Camera.ScreenCoordinatesToRay (Vector.New(0,0,0));<br><br> | ||
+ | Space.Log(cameraRay.Origin);<br> | ||
+ | Space.Log(cameraRay.Direction);<br> | ||
+ | ''-- 2 vectors (location of the ray origin (camera coordinates) and direction of the ray towards the origin) are printed to the console.''<br> | ||
}} | }} | ||
{{Scripting Navbox}} | {{Scripting Navbox}} |
The SCameraManager class allows you to take and manipulate the users camera. Combine with Scripting/SCamera to create 2D side-scrolling regions!
Returns true if the Camera is locked and can be manipulated by this script.
Space.Camera.LockCamera (obj);
Space.Log(Space.Camera.IsLocked);
Relinquishes control of the Camera back to Space
-- Let's lock the camera for a moment
Space.Camera.LockCamera (obj);
-- Now we can release it
if Space.Camera.IsLocked then
Takes control of the Camera as long as 'owner' exists in the scene, or until ReleaseCamera() has been called. Using the Host runtime as the owner is often a good practice.
Space.Camera.LockCamera (obj);
Forces the camera to be at position facing orientation for the frame. Needs to be called every frame.
local VectorPos = Vector.New(0,0,0);
local VectorRot = Quaternion.Euler(-60,0,0);
Space.Camera.LockCamera (obj);
Space.Camera.SetCameraPositionOrientation (VectorPos,VectorRot);
Returns a ray going from camera through a screen point.
local cameraRay = Space.Camera.ScreenCoordinatesToRay (Vector.New(0,0,0));
Space.Log(cameraRay.Origin);
Space.Log(cameraRay.Direction);
|