Resetcar
by CodingChris · in Torque Game Engine · 09/09/2007 (1:52 am) · 2 replies
Hi,
I'm trying to add a resetcar function to my game.
Here's my code:
This doesn't work, but I don't know why...
I'm trying to add a resetcar function to my game.
Here's my code:
function resetcar()
{
setloc($check);
}function setLoc(%newpos)
{
commandToServer('RelocatePlayer', %newpos) ;
}
function getLoc()
{
echo(ServerConnection.getControlObject().getTransform());
}function serverCmdRelocatePlayer(%client, %newpos)
{
%client.player.setTransform(%newpos);
}This doesn't work, but I don't know why...
About the author
Torque Owner Tim Heldna
The getLoc() function is never being called and doesn't do anything aside from echo out to the console - and the way you've done it won't work across a network.
If you're just trying to reset the car if it's flipped upside down, do this:
//----------------------------------------------------------------------------- // Used to flip the car over if it manages to get stuck upside down function serverCmdresetCar(%client) { %car = %client.getControlObject(); if (%car.getClassName() $= "WheeledVehicle") { %carPos = %car.getPosition(); %carPos = VectorAdd(%carPos, "0 0 3"); %car.setTransform(%carPos SPC "0 0 1 0"); } } // The key command for flipping the car moveMap.bindCmd(keyboard, "ctrl r", "commandToServer(\'resetCar\');", ""); //-----------------------------------------------------------------------------