Game Development Community

How to Change Camera Modes

by Matthew Genge · in Torque 3D Professional · 02/10/2012 (2:37 pm) · 6 replies

Dear All,

I am new to torque script...so permanently confused ;) I just thought I would experiment with camera mode. I've added the code to a script on the server:

%client.camera.setOrbitMode(%obj,"",5.0, 10.0, 5.0);

But when run it doesn't change the view, or the view is changed back. I don't really have a clue why, unless I am referencing the wrong camera?

Many thanks,
Matt


#1
02/10/2012 (3:00 pm)
Try putting some info in the whole in the transform instead of leaving it blank.

function serverCmdNewCam(%client, %obj)
{
   %client.camera.setOrbitMode(%obj, "0 1 0", 5.0, 10.0, 5.0, 0, "0 0 0.5", 0);
}

Also check out the Script Manual in the docs folder for more info.

void Camera::setOrbitMode  ( GameBase  orbitObject,  
  TransformF  orbitPoint,  
  float  minDistance,  
  float  maxDistance,  
  float  initDistance,  
  bool  ownClientObj = false,  
  Point3F  offset = Point3F(0.0f, 0.0f, 0.0f),  
  bool  locked = false   
 )    

Set the camera to orbit around the given object, or if none is given, around the given point. 

Parameters:
 orbitObject  The object to orbit around. If no object is given (0 or blank string is passed in) use the orbitPoint instead  
 orbitPoint  The point to orbit around when no object is given. In the form of "x y z ax ay az aa" such as returned by SceneObject::getTransform().  
 minDistance  The minimum distance allowed to the orbit object or point.  
 maxDistance  The maximum distance allowed from the orbit object or point.  
 initDistance  The initial distance from the orbit object or point.  
 ownClientObj  [optional] Are we orbiting an object that is owned by us? Default is false.  
 offset  [optional] An offset added to the camera's position. Default is no offset.  
 locked  [optional] Indicates the camera does not receive input from the player. Default is false.
#2
02/10/2012 (3:13 pm)
Additionally, check the Documentation under Scripting > Advanced > RTS Prototype for a hands-on walkthrough on how to do some of that.
#3
02/10/2012 (4:44 pm)
Dear Both,

Thanks for the advice, however, strangely it isn't working.

I've created a new project and added the code in the RTS tutorial. Specifically I've added the serverCmdoverheadCam function, then called it after %game.spawnplayer() in gameCore.cs. The level still starts in first person view. I haven't made any changes to the build so....

Ok, after experimenting I discovered that if I set the camera as the client's control object then I can change the camera mode.

%client.setControlObject(%client.camera);
%client.camera.setOrbitMode(%obj, "0 1 0", 1.0, 5.0, 5.0, 0, "0 0 0.5", 0);

This isn't really a solution since in orbitcam the camera direction is called by the mouse rather than pointing at the object. Setting the the control object back to the player shape automatically moves the camera back to first or third person and prevents me from changing camera mode. I am confused...either there is something fundamental I don't understand about the camera or I have a technical issue.

Matt
#4
02/13/2012 (9:03 am)
What are you trying to do? Did you change the Player to an AiPlayer as in the RTS code, or are you still using the Player class for the player?

The "control object" is the object that is being controlled. Thus, when the control object is the camera, you are controlling the camera. When the control object is the player, you are controlling the player. You can do a few different things with cameras and players, but the original system was designed around a first person shooter - so the camera is designed to pretty much stick with the player except during cinematic sequences (when you can't control the player).

This resource has been around for a while, but it might give you some ideas for adding more functionality to the camera.
#5
02/13/2012 (3:30 pm)
Hi Richard,

Thanks for that resource, I will have a dig around. No I didn't set the player as an AiPlayer, which probably explains my problem. I discovered I can set the cameraMaxDist of the shape I am mounting the player on as a rudimentary camera control...

Thanks,
Matt
#6
04/02/2012 (4:31 am)
Richard,

I been having a similar issue with the camera. How do I go about setting the camera to a path?

I created a path and added markers to it, now I want to set my camera to follow that path.

Thanks,
Euvin