Reputation: 3
I am creating a 2d sidescroller game. I have a point in space (where the mouse is) and I need the weapon to look and "follow" that point.
Does anyone know where to begin?
Upvotes: 0
Views: 1216
Reputation: 39089
wikihow: How to Find the Angle Between Two Vectors
After you have the angle, you can appropriately rotate the thing to be rotated.
I am not sure if javascript also has an atan2(x,y)
function, which could be used to get the angle.
Upvotes: 1