SCameraManager
| Property | IsLocked | Is the Camera locked? |
| Property | MainCamera | Note, this property is generally read-only. |
| Property | ActiveVirtualCamera | The currently active Cinemachine Virtual Camera game object. |
| Function | LockCamera | Calling this function stops the Camera from being controlled by the viewer, and allows us to control it until ReleaseCamera() is called. |
| Function | ReleaseCamera | Calling this function reverses the LockCamera() call and returns control of the Camera to the viewer. |
| Function | SetCameraPositionOrientation | Sets the Camera's position and rotation. |
| Function | ScreenCoordinatesToRay | Returns a ray going from camera through a screen point. |
| Function | ScreenCoordinatesToWorld | Transforms a point from screen space into world space. |
| Function | WorldCoordinatesToScreen | – |
| Function | ShakeCamera | – |
Properties
IsLockedRead only
Is the Camera locked?
Example
isCameraLocked = Space.Camera.IsLocked
MainCameraRead only
Note, this property is generally read-only. It's position is driven by internal code.
Example
mainCamera = Space.Camera.MainCamera
ActiveVirtualCameraRead only
The currently active Cinemachine Virtual Camera game object.
Example
currentCamera = Space.Camera.ActiveVirtualCamera
Functions
LockCamera
Calling this function stops the Camera from being controlled by the viewer, and allows us to control it until ReleaseCamera() is called.
Returns
void
Example
Space.Camera.LockCamera()
ReleaseCamera
Calling this function reverses the LockCamera() call and returns control of the Camera to the viewer.
Returns
void
Example
Space.Camera.ReleaseCamera()
SetCameraPositionOrientation
Sets the Camera's position and rotation. This function requires the camera to be locked.
Parameters
| Parameter | Type | Description |
|---|---|---|
| position | SVector | The World Postion of the camera GameObject. |
| orientation | SQuaternion | The World Rotation of the camera GameObject. |
Returns
void
Example
Space.Camera.SetCameraPositionOrientation (Vector.New(0,0,0),Quaternion.Euler(-60,0,0));
ScreenCoordinatesToRay
Returns a ray going from camera through a screen point.
Parameters
| Name | Type | Default |
|---|---|---|
| screenCoordinates | SVector | – |
Returns
SRay
Example
cameraRay = Space.Camera.ScreenCoordinatesToRay (Vector.New(0,50,0))
--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)
ScreenCoordinatesToWorld
Transforms a point from screen space into world space.
Parameters
| Name | Type | Default |
|---|---|---|
| screenCoordinates | SVector | – |
Returns
SVector
Example
obj = Space.Host.ExecutingObject;
Space.Log(Space.Camera.ScreenCoordinatesToWorld(Vector.New(0.5,0.5,0)).ToString());
-- Print 3 worldspace vectors created by screen space point to the console.
WorldCoordinatesToScreen
Parameters
| Name | Type | Default |
|---|---|---|
| coordinates | SVector | – |
Returns
SVector
Example
local trans = Space.Host.ExecutingObject;
Space.Log(Space.Camera.WorldCoordinatesToScreen(trans.WorldPosition).ToString());
-- Print the position created by world space point to the console.
ShakeCamera
Parameters
| Name | Type | Default |
|---|---|---|
| magnitude | float | – |
| time | float | – |
| amplitude | float | – |
| frequency | float | – |
Returns
void
Example
Space.Camera.ShakeCamera(1, 1.0)
--or
Space.Camera.ShakeCamera(2, 1, 1.0)



