Game Development Community

Limiting vehicle movement

by Troy Martin · in Torque Game Engine · 01/17/2004 (8:04 pm) · 8 replies

I'm still pretty new with torque so you'll have to keep things simple .. basically I want to limit a flying vehicle to so it can't move up and down, I want it to still be able to rotate in all directions but to just ignore whatever part of the thrust (or any other forces like gravity) that would move it up and down along the z axis while still allowing movement freely along the x and y axes. Any ideas how to go about this?

#1
01/17/2004 (9:21 pm)
Do you want it to conform to the terrain? Or fixed to a plane?
#2
01/18/2004 (8:24 am)
I'd like it to conform to a fixed plane. Also I said something a bit wrong in the first post, I don't want it to be able to rotate up and down either, but still want it to rotate freely on the other two axes. Thanks for any help you can give me.
#3
01/18/2004 (9:28 pm)
You could change some settings in flying vehicle.cs like lower the input thrust and adjust the drag but it may not be totaly stable,,i think you would have to modify engine code to make it totally stable?
#4
01/19/2004 (10:06 am)
Yeah, I'm figuring I'll probably have to modify the engine code to get it how I want. The way I think I might be able to do this is modify wherever it updates the position and not allow the z coord to be anything but the value I set it to. Then also do the same thing with rotating up and down and not let the rotation value change along that axis (can't remember, would that be the x axis?). The problem is I'm not sure which function(s) to change and what to change them to ..
#5
01/19/2004 (12:08 pm)
Vehicle::updatePos() should do it.
#6
01/20/2004 (6:54 pm)
Thanks, that put me right on the track of where I wanted to go. I'll put up roughly what else I've done to get it to behave how I wanted it to also in case anyone is interested, I don't claim that this is the best way, but it seems to be working fairly well for me so far .. What I did was edit Vehicle::updatePos() and through there I was able to make it so you couldn't steer up or down, but it would still kind of drift down and running into something could spin you around and make you face downward or upward so I went in and edited rigid.cc and basically everywhere it set the velocity to something I changed it to always make the z velocity be 0, then I also did more or less the same thing with the y angle (which is rotate the vehicle up and down). Then I also had to play around with a few of the values in the datablock for the vehicle over in the scripting. Again, I don't know that this was necessarily the best solution, but it seems to be working ok for me so far.
#7
01/20/2004 (10:57 pm)
0.o

It might best not to manipulate rigid.cc too much. It's used in more than just vehicles... You can force the same changes to occur without modifying it, too. Just stuff values into the appropriate members from the vehicle code...
#8
01/21/2004 (2:35 pm)
I was able to accomplish something close to what you describe by using a hoverVehicle. It's not perfect yet. I am still playing around with the numbers since I couldn't find any documentation, or even commented code, describing all of the hoverVehicle.cc persist fields.

Currently it moves along an x,y plane at the z height it is spawned at. I set floatingGravMag to 0.0 so that it stays level. It does not pitch or roll. That might have to do with rollForce and pitchForce being set to 0.0.

If you use the arrow keys to rotate it (what I want) the vehicle will not stop rotating on its own. My guess is that it is because in the default.bind.cs the turn functions set the yaw speeds to the keyboardTurnSpeed and setting them back to 0 afterwards is not enough to stop the rotation. So I am going to mess around with that function next.