Does anyone have a function that works to do this?
The Law of Cosines works. If it doesn't, you must be doing something wrong (or not be in Euclidian space, but you would have said if that was the case
). Since you don't go into detail, here are some things to check:
- You are using the right vectors. If player position is P and mouse is M, the angle from P to M, taking the Y axis as reference is acos([0,1] dot (M - P))
- You are not mixing radians with degrees. Remember SFML uses the later, while most other libraries, including <math> use radians.
- Mouse position is in the same coordinate system as player. See MouseToCoord and similar functions in renderTarget
I know it's kinda obvious stuff, but since you don't supply code, I am not sure what else you could be doing wrong.
Edit: If you need to know the direction (which point is behind the other), remember to use acos2, or that atan2 function you mention.