Just discover that I can sneak around the enemy and he’s still striking where I stood initially.
The solution is to move the FacePlayer() method to the top of Tick method in EnemyChasingState, and all works well again
public override void Tick(float deltaTime)
{
FacePlayer();
if (!IsInChaseRange())
{
stateMachine.SwitchState(new EnemyIdleState(stateMachine));
return;
}
else if (IsInAttackRange())
{
stateMachine.SwitchState(new EnemyAttackingState(stateMachine));
return;
}
MoveToPlayer(deltaTime);
stateMachine.Animator.SetFloat(SpeedHash, 1f, AnimatorDampTime, deltaTime);
}