Vehicles
by Thomas Glennow · in RTS Starter Kit · 01/02/2005 (11:55 am) · 4 replies
I've just started scripting vehicle-like movement for units (i.e. they have to move to be able to turn) but I wanted to check if anyone else has done it before so as to not duplicate work, and if anyone has any ideas as to how to implement it.
Right now I'm starting with a dot product of the current unit facing and the vector of the target location to establish which way to turn, and I'm trying to figure out how to actually move and turn the unit the right way.
Right now I'm starting with a dot product of the current unit facing and the vector of the target location to establish which way to turn, and I'm trying to figure out how to actually move and turn the unit the right way.
About the author
#2
Basically what I'm thinking is to iterate the angle each loop, so it moves forward and slightly to one side, until it faces the target.
01/02/2005 (12:37 pm)
Ah, sorry, I should've worded it more precisely. When I said turn the unit I meant the actual control of the angle of the vector so that it ends up somewhere between the current facing and the target's vector.Basically what I'm thinking is to iterate the angle each loop, so it moves forward and slightly to one side, until it faces the target.
#3
EDIT: You would need to modify the vector of travel per tick to only go in the direction the vehicle is currently facing, which might be a bit more work, but certainly doable if you have a basic understanding of vector math.
01/02/2005 (12:43 pm)
You could still use the same area of code, just don't allow it to instantly turn the entire angle. Instead, have it turn your "max turn angle per tick" (remember a tick is 32 milliseconds), and that combined with the normal "move to location" processing should give you a good point to start from.EDIT: You would need to modify the vector of travel per tick to only go in the direction the vehicle is currently facing, which might be a bit more work, but certainly doable if you have a basic understanding of vector math.
#4
01/02/2005 (4:33 pm)
Keep in mind that both the server and the client have to simulate the same thing, or you will get a lot of jumping around. In other words, don't change a units destination, just how gets there, or you will need to send updated info about the movement event.
Torque 3D Owner Stephen Zepp