Just looking at the FacePlayer/FaceTarget methods again and realised I had
protected void FaceTarget()
{
if (StateMachine.Targeter.CurrentTarget == null) { return; }
Vector3 facing = StateMachine.Targeter.CurrentTarget.transform.position - StateMachine.transform.position;
facing.y = 0f;
// ----------------------- The below line changes ---------------------
StateMachine.transform.forward = facing;
}
rather than
protected void FaceTarget()
{
if (StateMachine.Targeter.CurrentTarget == null) { return; }
Vector3 facing = StateMachine.Targeter.CurrentTarget.transform.position - StateMachine.transform.position;
facing.y = 0f;
// ----------------------- The below line changes ---------------------
StateMachine.transform.rotation = Quaternion.LookRotation(facing);
}
I’m not as up to snuff on Quaternions and how Unity actually handles rotations as i could be or enough to figure out if there is actually a difference in the result. From what I can figure out they should be the same. If that is the case is one is either more performant or more standard?