Shooting Towards Cursor Location

Hello,

I’ve been thinking of a small side project to work on when bored that uses the main mechanic of shooting towards the mouse location. All I need is a general explanation of setting the velocity to the correct number to correct go towards the location for shooting bullets.

I know how to get the location in an x and y on a Vector2 plane, how do I make the objects go towards that position. (Not go to it then stop, but just shoot in that direction).

Thanks!

  • A

Lots of these threads: https://www.google.com/#q=bullet%20mouse%20site%3Ajava-gaming.org

If you really want to fully understand it, heres some basic trygonometry :slight_smile:

EDIT: Theres also a way to do it using only Pithagoras and some divisions/multiplications/additions/substractions.

Don’t poison his mind with angles just yet! :stuck_out_tongue:

It will be useful for him in the future :slight_smile: You can also do some nice smooth animations with them.