This is probably a simple vector question, but I'm not sure how to do it.
I have an object at vector position (ox,oy)
. Potentially every update, the user walks around the screen, and will be at position (px,py)
at any given moment. How do I make it so that the object is always facing the player? I need to get the angle in degrees.
This is what I've been messing around with, but the direction doesn't immediately point to where the user is located. Instead, it slowly increments in the direction the user is walking in.
objVec.Normalize();
playerVec.Normalize();
obj.Rotation = MathHelper.ToDegrees((float)Math.Acos(Vector2.Dot(objVec, playerVec)));
I might be going about it completely wrong, so any help is appreciated!