From Wiki
Jump to: navigation, search

The SCameraManager class allows you to take and manipulate the users camera. Combine with Scripting/SCamera to create 2D side-scrolling regions!



bool IsLocked { get; }

Returns true if the Camera is locked and can be manipulated by this script.

obj = Space.Host.ExecutingObject;

Space.Camera.LockCamera (obj);

--prints "True" to the console


void ReleaseCamera ();

Relinquishes control of the Camera back to Space

obj = Space.Host.ExecutingObject;

-- Let's lock the camera for a moment
Space.Camera.LockCamera (obj);
-- Now we can release it
if Space.Camera.IsLocked then

Space.Camera.ReleaseCamera ();
Space.Log("Camera released");


void LockCamera (SGameObject owner);

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.

obj = Space.Host.ExecutingObject;

Space.Camera.LockCamera (obj);

-- If no camera position/orientation is set upon locking, the camera will lock on the avatar.


void SetCameraPositionOrientation (SVector position, SQuaternion orientation);

Forces the camera to be at position facing orientation for the frame. Needs to be called every frame.

obj = Space.Host.ExecutingObject;

local VectorPos = Vector.New(0,0,0);
local VectorRot = Quaternion.Euler(-60,0,0);

Space.Camera.LockCamera (obj);
Space.Camera.SetCameraPositionOrientation (VectorPos,VectorRot);

-- Now the camera is positioned at the global origin and is facing the sky at 60 degrees.


SRay ScreenCoordinatesToRay (SVector screenCoordinates);

Returns a ray going from camera through a screen point.

obj = Space.Host.ExecutingObject;

local cameraRay = Space.Camera.ScreenCoordinatesToRay (Vector.New(0,50,0));


-- 2 vectors (location of the ray origin (somewhere close to camera coordinates) and direction of the ray towards the point at (0,50,0)) are printed to the console.