Game Development Community

Vehicle steering

by Mark Miley · in Torque Game Engine · 04/21/2004 (12:36 am) · 8 replies

I've been searching through the forums on this, but to no avail. I got a hover vehicle working in the game and I wanted to change the steering controls. Right now it seems like all the vehicles turn with the mouse. The turning however is constant...like you turn the mouse a bit and the vehicle will continue to turn until you move the mouse back the other way. Not sure how to accurately explain it. Anyway how would I change that so it functioned more like the freefly camera? So that you just turn to a direction and stay pointed in that direction.

I scanned throught the engine and the script looking for the freefly code, but couldn't nail down what I was looking for. I also noticed that the key binding script for the turning was using a += so I changed it to just = and still nothing. where exactly is the vehicle steering controls hidden? Thanks.

#1
04/21/2004 (6:54 am)
Try this its for stearing with keys,maybe it helps.
#2
04/21/2004 (11:53 am)
OK...still confused. Basically I still want the vehicle controlled by the mouse, but for the yaw rotation to be more like that of the human players. You turn in a direction and stop. I'm not sure why I didn't realize I wanted it more like the player from the beginning. Looking through the player code didn't make much sense on how they got the yaw set.
#3
04/21/2004 (3:48 pm)
You might need to have a maximum turning speed though, I'm not sure if the code is set up like that. it probably uses standard mouse input
#4
04/23/2004 (2:13 pm)
I fixed the steering to my liking. The change was rather simple actually..not sure why i didn't see it before. Made some changes to the vehicle.cc

if (move != &NullMove) {
      F32 y = move->yaw;
      mSteering.x = mClampF(mSteering.x + y,-mDataBlock->maxSteeringAngle, mDataBlock->maxSteeringAngle);

I changed that section of code in the updatemove function to this:

if (move != &NullMove) {
      F32 y = move->yaw;
      if (y > M_PI) y -= M_2PI;
      mSteering.x = y*(mDataBlock->SteeringSpeed);

I also added the SteeringSpeed variable to the vehicle datablock so I can adjust the steering speed in script. Basically all this does is make it so you don't continue to turn when moving the mouse a little. You can turn to a direction and will stop. Like that of the player. Not sure if this is usefull to anyone or not, but I figure I would post my solution incase anyone was curious. Just trying to give back to the community. :)
#5
04/23/2004 (3:01 pm)
I think you should still clamp the value with the maxSteeringAngle, else the player could move the mouse a lot and it will steer that much... you don't want that... there should be a maxium the vehicle can steer.
mSteering.x = mClampF((y*mDataBlock->SteeringSpeed), -mDataBlock->maxSteeringAngle, mDataBlock->maxSteeringAngle);

EDIT: Added your steering speed variable.
#6
04/24/2004 (11:00 am)
Thanks for the idea. I had thought about that myself and after some testing I definitely agree. The player right now can whip themselves into a frenzy of turning. It's kinda fun actually, but might get annoying during a critical situation. Thanks. :)
#7
09/14/2007 (10:02 am)
Hi,
I'm using an instance of a flying object and i'd like to modify the commands so that when i modify the pitch (using the mouse) the vehicle doesn't eventually go back to its original position but keeps on pointing in that same direction that i've chosen. This is pretty much what you were talking about but with pitch instead of yaw !

Do you guys have any idea how to change that ?
Thanks !
#8
01/03/2008 (7:33 am)
Good stuff.

BTW, is there any way to do the above thing only within Torque Script?

The following link is similiar subject one:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6305