Hello community,

I do not know how to make enemies chase the player.

I already have the code to find the angle the enemy needs to shoot at

to hit the moving player, and how to steer to it.

(I don't want to make them cheat, they need to use their left-/right-jets like the player).

But how do I find out which translational acceleration needs to be applied?

The challenge is to cope with the different physical attributes the ships have.

Enemies might be much faster than the player, or much more inert.

If I let them accelerate continuously, they are much too fast and rush by the player

and can't rotate fast enough back which makes them lose the player

(they can accelerate translational into the direction they head to and rotational left-/right)

If I take the braking distance into account, they try to approach the point where the player

is, which works, but if the player moves it results in too slow enemies because the

braking distance is higher than the actual distance to the ship and they slow down.

I tried vector projection, to find out how much the velocity of an enemy matches with

the direction to the player or the player's velocity, but that didn't help me either.

I hope you understood my problem: How do I take the player's velocity into account to find

the translational acceleration an enemy needs to have to chase it?

Here are the properties a ship has, I hope it helps you:

int Mass { get; set; } float TranslationalAcceleration { get; set; } float RotationalAcceleration { get; set; } float TranslationalFriction { get; set; } // Amount the velocity vector is reduced each second float RotationalFriction { get; set; } float MaxTranslationalVelocity { get; set; } float MaxRotationalVelocity { get; set; }

Here is the code for the rotational acceleration, in case you need it:

public float ApproachAngle(float desiredAngle) { if (Math.Abs(desiredAngle) > .001f) { if (Physics.GetBrakingDistance(Math.Abs(ship.WorldRotationalVelocity), ship.RotationalAcceleration / ship.Mass + ship.RotationalFriction) > Math.Abs(desiredAngle)) { return -MathHelper2.GetSign(desiredAngle); } else { return MathHelper2.GetSign(desiredAngle); } } else return 0; } public float GetIntersectionOffset(float currentAngle, Vector2 targetVelocity, float ammoVelocity) { float tangential = targetVelocity.RotateBy(-currentAngle).Y; return MathHelper2.GetAngle(new Vector2((float)Math.Sqrt(Math.Pow(ammoVelocity, 2) - Math.Pow(tangential, 2)), tangential)); }

It would be very nice if you help me.

Phil