Game Development Community

FPS to Racing on the fly

by Robert Doyle · in Torque Game Engine · 07/27/2005 (11:13 am) · 2 replies

I am working on a game idea where the player will be able to enter and exit a vehicle while in the game. What are the appropriate steps to do this transition?

I was looking through the forums and they said something about switching gui's, but I am not seeing any type of true answer to this on the forums.

this is the code I found in the Racing demo. (.\server\scripts\game.cs)
%cl = ClientGroup.getObject( %clientIndex );
%cl.setControlObject(%cl.car);

I then implimented this into the tutorial as a bound key, specifically to switch from a fps to a car. (./client/defult.bind.cs)

function testSwitch()
{
   exec("~/server/car.cs");
   %cl = ClientGroup.getObject( %clientIndex );
   %cl.setControlObject(%cl.car);
   exec("~/client/config.cs");
}


And of course the game froze, then bombed... LOL

Any help with this would be greatly appreciated.

#1
07/27/2005 (12:00 pm)
You really don't want to be doing execs in function calls. Those are loading entire scripts. Should you do it more than once, you're loading the script more than once.

- Brett
#2
07/27/2005 (4:18 pm)
@Robert,

3DGPAI1 have a good example on how to do that. You really don't want to mix both resources. What you want to do is have a car object in your game and use the mount command to mount your player in it with one key. It's not that hard to do.