Game Development Community

Let wheels automatically turn back

by Very Interactive Person · in Torque Game Engine · 05/03/2004 (5:09 pm) · 3 replies

I'm using standard wheeled vehicles in my game, and another dev asked me if it would be possible to change this so the wheels level out when you release the left or right key. Currently they stay "turned". We would like them to turn back to their original position when you release the key... and offcourse not immidiately, but slowely.

The thing is I'm sure this will have to be done in C++ code, and I'm a total dumbo when it comes to that. Can anyone give me some ideas/get me started?

#1
05/03/2004 (5:15 pm)
Read This
#2
05/27/2004 (6:52 am)
Owk... I have added something like described in that thread. But... I'm thinking, its using a commandToServer, so, this means that player with higher pings have their wheels turned back slower then players with lower pings, right?
Also, the wheels turn back immidiately, they should turn back slowely. Anyone with more C++ knowledge willing to take a look?
#3
05/27/2004 (8:11 am)
I'm guessing it wouldn't be too hard to do an engine only fix. I mean, you have the YawLeftSpeed and the YawRightSpeed, right? If both are equal to 0, then the wheels should turn back.

so:

if (YawRightSpeed == 0 and YawLeftSpeed ==0){
if (mSteering.x > 0){
mSteering--
}else{
mSteering.x++
}
}

The above is no code... just what I believe would be the logic behind it. Anyone with some Torque and C++ experience willing to take a look. I'm sure a lot of people would like to see this one fixed. Is too hard to drive vehicles as its set up now (you easely loose control...having the wheels turned back really helps)

[note]
I just tought I found a script solution, but it doesn't work, it turns the wheels completely after key release (so not only turning back, but further, so they turn to the opposite direction. This was what i tried:

function turnLeft( %val )
{
   $mvYawRightSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : -$Pref::Input::KeyboardTurnSpeed;
}

function turnRight( %val )
{
   $mvYawLeftSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : -$Pref::Input::KeyboardTurnSpeed;
}
[/note]