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:
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
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
About the author
I am an Earth Scientist who likes writing games for fun.
#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
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.
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
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
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.
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
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
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
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
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
Associate Steve Acaster
[YorkshireRifles.com]
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.