The problem I'm having is: If I try to set the players rotation (unsecure, I know), the player looks in the wrong direction.
Oh god its too late at night.... I think I'm missing something very obvious here.
Code:
public void move() {
Vector2 playerLocation = new Vector2(getPlayer().getLocation().X, getPlayer().getLocation().Y);
Vector2 currentWaypoint = Waypoints[wpWalkIndex];
float playerRotation = (float)(getPlayer().getRotation() * (180 / Math.PI)); // Not being used. What am I missing?
float tRotation = getNormalizedAngle(getLinearAngle(playerLocation, currentWaypoint));
Magic.WriteFloat(getPlayer().BaseAddress + (uint)Pointers.WowObject.RotationOffset, (float)tRotation); // Doesnt work
Magic.WriteFloat(getPlayer().BaseAddress + (uint)Pointers.WowObject.RotationOffset, (float)(getPlayer().getPlayerRotation() + tRotation)); // I tried both versions
}
private float getLinearAngle(Vector2 from, Vector2 to) {
Vector2 difVector = new Vector2(to.X - from.X, to.Y - from.Y);
float fAngle = (float)Math.Atan2(difVector.Y, difVector.X);
return fAngle;
}
private float getNormalizedAngle(float fAngle) {
if (fAngle < 0f)
fAngle += (float)Math.PI * 2.0f;
else if (fAngle > (float)(Math.PI * 2.0f))
fAngle -= (float)Math.PI * 2.0f;
return fAngle;
}