Game Development Community

Get player out of a vehicle

by Liu Yi · in Torque Game Engine · 11/17/2006 (4:33 am) · 2 replies

I'm trying to built a game where the player can drive vehicles. When the player is driving a vehicle, and wants to get out of it, the player is supposed to appear next to the vehicle. I use the following method.

function serverCmdgetOutVehicle(%client)
{
%client.setControlObject(%client.player);
%player=%client.player;
%TF=%player.getTransform();
%newTF=setWord(%TF,1,getWord(%TF,1)+10);
echo("old transform", %TF);
echo("new transform", %newTF);
%player.setTransform(%newTF);
echo("new transform of the player", %player.getTransform());
}

It turns out that the player still gets stuck in the vehicle. In addition, the console shows that the transform of the player is unchanged. Can anyone tell me what's wrong here? And is there any better way to get the player out of a vehicle?

#1
11/17/2006 (4:59 am)
Im by no means a coder but I think you need to Unmount(disMount?) the player from the vehicle.
I would assume since the player is already mounted that setting any transform wouldnt
move him(The player) seperate from the vehicle.

This is a Quick Flag Mounting and Unmounting I just found.
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5199

This is an old thread with someone who had the same problem. Dont know if it applies
http://www.garagegames.com/mg/forums/result.thread.php?qt=8926

And this link I think should do the Trick. Its from TDN
http://tdn.garagegames.com/wiki/DTS/Scripting/Vehicles/Guide

Good luck.

-Surge
#2
11/17/2006 (8:18 pm)
Function Armor::doDismount is in player.cs in the starter.fps. I modified the vectors in there;

%vec[0] = " -1 0 1";
%vec[1] = " 0 0 1";
%vec[2] = " 0 0 -1";
%vec[3] = " 1 0 0";
%vec[4] = "-1 0 0";

and it worked for me.