Directing a bullet

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Chisk3n0

I’m doing a top-down shooter game and i need to direct the bullet to its weapon direction,
The direction is rappresented by a Vector2, then i’m going to add this value to the position:

position += direction/Vector2

how can i get the dircetion of the bullet?

:bust_in_silhouette: Reply From: joakim1999

Is the bullet pointing the same direction as the weapon?
Then you can simply use:


to get the direction vector. This you can multiply by the speed of the bullet.

If not, rotate the bullet to point the same way as the weapon first.

EDIT: Sry, this is only for 3D transforms. For 2D I have personally used -transform.y to move forward