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

Hi, just chiming in to say I’m fighting with a similar issue, while the agent is set to isStopped = true. I’ve tried setting updateRotation = false, then both transform.rotation and FollowerEntity.rotation to my desired quaternion, and it all works as expected. But as soon as I turn on rotation sync updateRotation = true, it resets to the previous value. (A* version 5.2.4, Unity 6).

2 Likes

Hello, I just wanted to bump this one more time to see if anyone has found a solution for this or if this can be changed for the next update :slight_smile: :pray:

I believe I did some tweaks for this in 5.2.5. Could you try that version?

I tried it with version 5.2.5, but the issue remains the same. (Current Unity version is 6)

1 Like