Game Development Community

dev|Pro Game Development Curriculum

Fix default camera controls

by Orion Elenzil · 11/27/2005 (10:47 pm) · 6 comments

No biggie, but these have been bugging me for a while.

Fixing F7:
In stock TGE 1.3, F8 will drop the camera at the player, but to enable F7 to drop the player back at the camera, you have to first open and then close the world editor. (F11) Trivial but annoying.

.../server/init.cs
// Turn on testing/debug script functions[i]
   // So far this seems to be ONLY USED for drop player at camera.
   $Server::TestCheats = true;[/i]

an alternative fix for this, depending on your tastes, is:

.../server/commands.cs
change this:
function serverCmdDropPlayerAtCamera(%client)
{
   if ($Server::TestCheats || isObject(EditorGui))
   {
      %client.player.setTransform(%client.camera.getTransform());
      %client.player.setVelocity("0 0 0");
      %client.setControlObject(%client.player);
   }
}

to this:

%client.player.setTransform(%client.camera.getTransform());
   %client.player.setVelocity("0 0 0");
   %client.setControlObject(%client.player);



Enabling Camera Speed via Shift 1-5:
Once you hit F8 to drop the camera at the player, you can fly around but sometimes you'd like to adjust the flying speed.
In stock TGE 1.3, you have to open the world editor to do this. Trivial but annoying.
Don't forget to blow away .../client/config.cs after making this change.

.../client.cs/default.bind.cs
moveMap.bind(keyboard, "F8", dropCameraAtPlayer);
moveMap.bind(keyboard, "F7", dropPlayerAtCamera);

[i]
function oxe_CameraSpeed(%val)
{
   $Camera::movementSpeed = 3 + (%val-1)*15;
}

moveMap.bindCmd(keyboard, "shift 1", "oxe_CameraSpeed(\"1\");", "");
moveMap.bindCmd(keyboard, "shift 2", "oxe_CameraSpeed(\"2\");", "");
moveMap.bindCmd(keyboard, "shift 3", "oxe_CameraSpeed(\"3\");", "");
moveMap.bindCmd(keyboard, "shift 4", "oxe_CameraSpeed(\"4\");", "");
moveMap.bindCmd(keyboard, "shift 5", "oxe_CameraSpeed(\"5\");", "");
[/i]
function bringUpOptions(%val)
{
   if (%val)
      Canvas.pushDialog(OptionsDlg);
}

#1
11/27/2005 (10:48 pm)
Thanks Orion :)
#2
12/02/2005 (12:27 pm)
Nice, but keep in mind that the reason for doing F11 before F7 is to prevent people cheating in game.

Why run arround looking for the enemy when you can fly unseen and then F7 behind them, then shoot the crap out of them... F11 only works on the server, not the client thus it stops clients from cheating. Well that was the original idea anyway.
#3
12/02/2005 (12:32 pm)
Good point, this should be disabled for production releases.

For development tho it's nice to allow clients to zoom anywhere.

You probably want to disable F8 too in real releases if you're worried about cheating..
#4
12/11/2005 (7:25 pm)
@Duncan: I did that in a alpha testing. Was funny as heck, they were all like "AHH WHAT THE HECK".
#5
07/14/2008 (7:20 pm)
Orion, thank you so much! Cycling F11 was annoying.
#6
07/15/2008 (8:40 am)
right on!