There is a rotation issue with `followerEntity` when setting isStopped

a* version: 5.2.3
unity version: 22.3.21f1

graph: recast graph
ai: followerEntity

There is a rotation issue with followerEntity. For example, when the unit goes into an attack, followerEntity.isStopped is set to true.

During the attack animation, the unit is made to look at the target using transform.LookAt(target.position).

However, when the attack is finished, and followerEntity.isStopped is restored to false, the unit’s rotation returns to the position it was in when isStopped was first set to true.

This is a Video to help with your understanding.
Example video

This is my code in Animator State Behavior.


public class ZombieSMBAttack : SceneLinkedSMB<Zombie>
{

  // Attack State Enter
  public override void OnSLStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
  {
    m_unit.IsAttacking = true;
    m_unit.ai.isStopped = true;
  }

  // Attack State Update
  public override void OnSLTransitionToStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
  {
    LookTarget();
  }

  // Attack State Update
  public override void OnSLStateNoTransitionUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
  {
    LookTarget();
  }

  // Attack State Exit
  public override void OnSLStatePreExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
  {
    m_unit.IsAttacking = false;
    m_unit.ai.isStopped = false;
  }

  void LookTarget()
  {
    if (m_unit.Target != null && m_unit.Target.IsAlive)
    {
      m_unit.transform.LookAt(m_unit.Target.transform);
    }
  }
}

Hi

This is by design right now. I’m considering changing it, though.

1 Like

I hope this doesn’t come across as presumptuous, but I believe it would be better to allow users to adjust the rotation values. As it stands, someone unfamiliar with the feature might perceive it as a bug. I hope this feedback is helpful.

1 Like

Definitely helpful, thank you for sharing! It’s always nice to hear outside thoughts on projects like this.

1 Like