m |
|||
Line 42: | Line 42: | ||
}} | }} | ||
+ | {{ScriptFunction|SGameObject|MainCamera|;|Note, this property is generally read-only. It's position is driven by internal code.|5= | ||
+ | obj = Space.Host.ExecutingObject;<br> | ||
+ | Space.Log(Space.Camera.MainCamera.Name); <br> | ||
+ | ''--print "Main Camera" to the console.''}} | ||
+ | |||
+ | {{ScriptFunction|SGameObject|ActiveVirtualCamera|;|Get the currently active Cinemachine Virtual Camera game object.|5= | ||
+ | obj = Space.Host.ExecutingObject;<br> | ||
+ | Space.Log(Space.Camera.ActiveVirtualCamera.Name); <br> | ||
+ | ''--print "Virtual PlayerCamera" to the console.''}} | ||
+ | |||
+ | {{ScriptFunction|SVector|ScreenCoordinatesToWorld|(SVector screenCoordinates);|Transforms a point from screen space into world space.|5= | ||
+ | obj = Space.Host.ExecutingObject;<br> | ||
+ | Space.Log(Space.Camera.ScreenCoordinatesToWorld(Vector.New(0.5,0.5,0)).ToString());<br><br> | ||
+ | ''-- Print 3 worldspace vectors created by screen space point to the console.''<br> | ||
+ | }} | ||
+ | |||
+ | |||
+ | {{ScriptFunction|SVector|WorldCoordinatesToScreen|(SVector coordinates);|Transforms position from world space into screen space.|5= | ||
+ | local trans = Space.Host.ExecutingObject;<br> | ||
+ | Space.Log(Space.Camera.WorldCoordinatesToScreen(trans.WorldPosition).ToString());<br><br> | ||
+ | ''-- Print the position created by world space point 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,50,0));
Space.Log(cameraRay.Origin);
Space.Log(cameraRay.Direction);
Note, this property is generally read-only. It's position is driven by internal code.
Space.Log(Space.Camera.MainCamera.Name);
Get the currently active Cinemachine Virtual Camera game object.
Space.Log(Space.Camera.ActiveVirtualCamera.Name);
Transforms a point from screen space into world space.
Space.Log(Space.Camera.ScreenCoordinatesToWorld(Vector.New(0.5,0.5,0)).ToString());
Transforms position from world space into screen space.
Space.Log(Space.Camera.WorldCoordinatesToScreen(trans.WorldPosition).ToString());
|