Game Development Community

Vehicle Speed

by Xavier "eXoDuS" Amado · in Torque Game Engine · 10/06/2002 (11:15 am) · 6 replies

How would you get the vehicle's speed in the engine code for use on a gui control?
getVelocity returns a 3 dimensional point... what's this?

Thanks.

#1
10/06/2002 (11:21 am)
Velocity is speed plus the direction. Maybe you want something like this:

Quote: %vel = %vehicle.getVelocity();
%speed = vectorLen(%vel);
#2
10/06/2002 (11:42 am)
There is also a global script function
getControlObjectSpeed()
which should give you what you're looking for...
#3
10/06/2002 (12:51 pm)
Thanks a lot guys
#4
10/06/2002 (1:39 pm)
Mmmm.... this speed.... what speed is it? because it seems to include the 3 vectors... if you fall or climb it affects the speed too... how would i limit this to the linear speed?
#5
10/06/2002 (3:55 pm)
Just zero out the Z component, something like this:

%linspeed = GetWord(%vel, 0) @ " " @ GetWord(%vel, 1) @ " 0";
%speed = VectorLen(%linspeed);
#6
10/07/2002 (2:33 pm)
Thank you, but since I was doing this from the engine code it was even simpler :)

vel.z = 0;

voila! heh :)
Thanks guys