How can I implement aim/target assist in C# XNA?

204 views Asked by At

I am creating a 2D top-down tank game in which the player can rotate their tank's turret to shoot the enemy. What I'd like to implement is an 'aim assist' feature to help the player judge the direction of the turret/bullet. Here is a screenshot of what I'm trying to achieve:

Screenshot

I don't intend to draw the white dotted line, but used it to show what I'm trying to do. The tank has a radius around it which represents the distance that its bullet will travel when fired. If an enemy gets within the line of sight of my 'aim assist target,' I'd like it to snap onto the enemy. I use circular collision for the enemy.

I think this can be done using line-circle collision detection, however I'm unsure how to implement this. Perhaps there's another way this feature can be made.

Thanks in advance!

0

There are 0 answers