wiki.sine.space | sinespace

Difference between revisions of "Scripting/SCameraManager"

From wiki.sine.space
Jump to: navigation, search
(Created page with "The SCameraManager class allows you to take and manipulate the users camera. Combine with Scripting/SCamera to create 2D side-scrolling regions! ==Members== {{ScriptFunct...")
 
(Added examples to: IsLocked, ReleaseCamera, LockCamera, SetCameraPositionOrientation)
Line 2: Line 2:
  
 
==Members==
 
==Members==
{{ScriptFunction|bool|IsLocked|{ get; }|Returns true if the Camera is locked and can be manipulated by this script.}}
+
{{ScriptFunction|bool|IsLocked|{ get; }|Returns true if the Camera is locked and can be manipulated by this script.|5=
{{ScriptFunction|void|ReleaseCamera|();|Relinquishes control of the Camera back to Space}}
+
obj = Space.Host.ExecutingObject;<br><br>
{{ScriptFunction|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.}}
+
Space.Camera.LockCamera (obj); <br>
{{ScriptFunction|void|SetCameraPositionOrientation|(SVector position, SQuaternion orientation);|Forces the camera to be at position facing orientation for the frame. Needs to be called every frame.}}
+
Space.Log(Space.Camera.IsLocked); <br>
 +
''--prints "True" to the console''}}
 +
 
 +
{{ScriptFunction|void|ReleaseCamera|();|Relinquishes control of the Camera back to Space| 5=
 +
obj = Space.Host.ExecutingObject;<br><br>
 +
 
 +
''-- Let's lock the camera for a moment''<br>
 +
Space.Camera.LockCamera (obj);<br>
 +
''-- Now we can release it''<br>
 +
if Space.Camera.IsLocked then<br>
 +
:Space.Camera.ReleaseCamera ();<br>
 +
:Space.Log("Camera released");<br>
 +
end}}
 +
 
 +
{{ScriptFunction|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.|5=
 +
obj = Space.Host.ExecutingObject;<br><br>
 +
Space.Camera.LockCamera (obj);<br>
 +
''-- If no camera position/orientation is set upon locking, the camera will lock on the avatar.''}}
 +
 
 +
{{ScriptFunction|void|SetCameraPositionOrientation|(SVector position, SQuaternion orientation);|Forces the camera to be at position facing orientation for the frame. Needs to be called every frame.|5=
 +
obj = Space.Host.ExecutingObject;<br>
 +
local VectorPos = Vector.New(0,0,0);<br>
 +
local VectorRot = Quaternion.Euler(-60,0,0);<br><br>
 +
Space.Camera.LockCamera (obj);<br>
 +
Space.Camera.SetCameraPositionOrientation (VectorPos,VectorRot);
 +
''-- Now the camera is positioned at the global origin and is facing the sky at 60 degrees.''<br>
 +
}}
  
 
{{Scripting Navbox}}
 
{{Scripting Navbox}}

Revision as of 10:32, 18 July 2017

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

Members

IsLocked

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);
Space.Log(Space.Camera.IsLocked);

--prints "True" to the console


ReleaseCamera

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");
end


LockCamera

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.


SetCameraPositionOrientation

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.