Setting default camera view for RTS mission
by Uri Kareev · in RTS Starter Kit · 12/27/2004 (10:56 pm) · 4 replies
Hi,
I am trying to change the default view of an RTS mission but there are a couple of things i can't seem to find out how to do:
1. setting the default position of the camera.
2. setting the default pitch. The problem with this one is that even though i set the pitch in camera.cs the camera seems to "fall down" and the pitch is changed when the mission starts.
Thanks
I am trying to change the default view of an RTS mission but there are a couple of things i can't seem to find out how to do:
1. setting the default position of the camera.
2. setting the default pitch. The problem with this one is that even though i set the pitch in camera.cs the camera seems to "fall down" and the pitch is changed when the mission starts.
Thanks
About the author
#2
In serverConnection.cs, RTSConnection::initialControlSet(), add the following to the bottom of the last scope block:
after:
after that function, add the following new function:
in server/scripts/core/gameConnection.cs, add the following function:
NOTE: This is a hand-written set of modifications to how we did things, so it possibly won't work right out of the box--I consolidated it a bit for presentation purposes. Shouldn't be hard at all to adjust however.
Second NOTE: This is blatently hack-like. It's here mostly for technique demonstration purposes!
If you wanted to define certain starting camera settings such as pitch, etc., you would want to add them to the array strings in getStartingCameraLocation(), and then decode them in clientCmdAcceptStartingCameraLocation().
We did it in this way because the client and server were asynch at this stage, and we needed to update the camera's position based on what team the server assigned to the client. Using an Ack back and forth between the client and server seemed to work well.
12/29/2004 (6:47 am)
It's actually a bit hard coded unfortunately, and took some effort for us to get working well so that you could force an initial camera position from the server. Here's what we did:In serverConnection.cs, RTSConnection::initialControlSet(), add the following to the bottom of the last scope block:
after:
$RTSCamera.setPitchAngle( 60 );
$RTSCamera.setCameraPosition( -40, -57 );addcommandToServer('InitialControlSetCameraAck');after that function, add the following new function:
function clientCmdAcceptStartingCameraLocation(%location)
{
echo("clientCmdAcceptStartingCameraLocation--changing cam to (" @ %location @ ")");
$RTSCamera.setCameraPosition(getWord(%location, 0) , getWord(%location, 1) );
}in server/scripts/core/gameConnection.cs, add the following function:
function RTSConnection::getStartingCameraLocation()
{
// you need to write code here to figure out where the server
// wants the client's camera to start. We created an array
// for testing purposes of various start spots for clients
// based on their team, something like:
// very poor initial spawn location hack
%startingLocArray[8] = "-500 -500 0";
%startingLocArray[7] = "-500 0 0";
%startingLocArray[6] = "-500 500 0";
%startingLocArray[5] = "0 -500 0";
%startingLocArray[4] = "0 0 0";
%startingLocArray[3] = "0 500 0";
%startingLocArray[2] = "500 -500 0";
%startingLocArray[1] = "500 0 0";
%startingLocArray[0] = "500 500 0";
return (%startingLocArray[%this.getTeam()]);
}
function serverCmdInitialControlSetCameraAck(%client)
{
%clientStartLocation = %client.getStartingCameraLocation();
// echo("serverCmdInitialControlSetCameraAck--telling client to move the camera to (" @ %clientStartLocation @ ")");
commandToClient(%client, 'AcceptStartingCameraLocation', %clientStartLocation);
}NOTE: This is a hand-written set of modifications to how we did things, so it possibly won't work right out of the box--I consolidated it a bit for presentation purposes. Shouldn't be hard at all to adjust however.
Second NOTE: This is blatently hack-like. It's here mostly for technique demonstration purposes!
If you wanted to define certain starting camera settings such as pitch, etc., you would want to add them to the array strings in getStartingCameraLocation(), and then decode them in clientCmdAcceptStartingCameraLocation().
We did it in this way because the client and server were asynch at this stage, and we needed to update the camera's position based on what team the server assigned to the client. Using an Ack back and forth between the client and server seemed to work well.
#3
change
function RTSConnection::getStartingCameraLocation()
to
function RTSConnection::getStartingCameraLocation(%this)
change
commandToClient(%client, AcceptStartingCameraLocation, %clientStartLocation);
to
commandToClient(%client, 'AcceptStartingCameraLocation', %clientStartLocation);
change
commandToServer(InitialControlSetCameraAck);
to
commandToServer('InitialControlSetCameraAck');
06/10/2005 (3:42 pm)
Thanks, it worked nicely. After the following fixes;change
function RTSConnection::getStartingCameraLocation()
to
function RTSConnection::getStartingCameraLocation(%this)
change
commandToClient(%client, AcceptStartingCameraLocation, %clientStartLocation);
to
commandToClient(%client, 'AcceptStartingCameraLocation', %clientStartLocation);
change
commandToServer(InitialControlSetCameraAck);
to
commandToServer('InitialControlSetCameraAck');
#4
1. I have the ability to select a AIPlayer. (That's right. I have not yet switched to RTSUnit but I am considering it).
2. I have a "Find" button, i.e. little binoculars on the bottom of the screen. When the player clicks this button, I want to change the position of the camera to be a little above, tilted, and 5 units -Y of the player.
Everything works except the call to setCameraPosition(). I need to understand why it's not working and fix it.
Some other good news... I'm not using RTSUnit, RTSConnection, etc. So far I am only using RTSCamera so maybe this is why?
Thanks.
Robert
11/26/2007 (12:14 am)
Hi. I know this post is old, but could anyone please offer me some advice on the RTSCamera Object?1. I have the ability to select a AIPlayer. (That's right. I have not yet switched to RTSUnit but I am considering it).
2. I have a "Find" button, i.e. little binoculars on the bottom of the screen. When the player clicks this button, I want to change the position of the camera to be a little above, tilted, and 5 units -Y of the player.
Everything works except the call to setCameraPosition(). I need to understand why it's not working and fix it.
Some other good news... I'm not using RTSUnit, RTSConnection, etc. So far I am only using RTSCamera so maybe this is why?
Thanks.
Robert
Torque 3D Owner Martin "Founder" Hoover