RTS style movement of units at zero gravity...

jeti
Posts: 6
Joined: Tue Sep 07, 2010 10:35 pm

RTS style movement of units at zero gravity...

Post by jeti »

Hi everyone,

I'm trying to integrate bullet into a realtime strategy game. The units are spaceships, so gravity is zero and there is no need for wheels. Every unit is composed of several ridgid bodies connected with locked generic6dof constraints. It works fine so far. Now I want to move the units, as known from such games... a targets is specified, the unit turns and moves into that direction.

I tried quite a few different approaches. I had trouble working with the angles of the units current rotation, as there are ambiguous solutions to describe it. I noticed that the functions that yield the Euler angles have a switch to chose between two solutions, but still the angles behaved different from what I would expect/want (like when rotating the unit they start at 0, went to PI/2 at quarter of the rotation but then go back to 0 for half a rotation....and I observe how the other angles I'm not interested in flip).

Another thing I tried is to apply a force in direction of the target to the unit. This didn't work to bad. The unit turns and moves towards the target. I then played with damping to get it stop at that position. But still, the movement doesn't look too plausible and leads to weird unwanted rotations around the other axis.

So after a few days trying I looked through the list of games and demos here, but I didn't find anything suiting. Most use FPS-style cameras or keys to steer a vehicle. I couldn't find anything in the sense of 'turn and fly to position'.

Maybe someone has an idea or knows a good example / demo / open source game showing something like that?

Thanks in advance!
jeti
jeti
Posts: 6
Joined: Tue Sep 07, 2010 10:35 pm

Re: RTS style movement of units at zero gravity...

Post by jeti »

any ideas?
Antodologo
Posts: 21
Joined: Sat Feb 06, 2010 3:40 am

Re: RTS style movement of units at zero gravity...

Post by Antodologo »

Hi

You are trying to solve two problems at the same time and they are really the same problem. Solve the linear movement (I think this one is easier) and you will be able to solve the orientation to destination.

Forget damping and friction, you are in space ;)

To solve linear movement you need to know "the speed you want your unit to move at" towards destination. This should depend on the distance to destination and, maybe, a maximum speed allowed for the unit. If the current speed of the unit is lower than the supposed velocity, apply a force towards destination. If it is greater apply a force in the opposite direction.

All you need to know is the "expected speed" towards destination depending on distance to destination and adjust the force to apply to "accelerate" and "decelerate" (take into account this force depends on the mass of the unit to apply the desired acceleration).

We are doing something similar with our enemies in our game Kromaia: http://www.krakenempire.com/kromaia/media.html#Videos

Hope this helps somehow ;)