- A* version: [5.1.4]
- Unity version: [2022.3+]
I am using RichAI to control monster’s movement. One behavior is that :
after monster reaches destination , it rotates to Player and shoot a magic attack.
on this part, I simply use tranform.Lookat( player transform ) to implement it.
public virtual void FeaturedMoveBehavior() // this method is call within OnUpdate() method
{
if (!isEscaping)
{
SwitchState(MonsterIdleState);
return;
}
if (pathPoints.Count < 1)
{
SwitchState(MonsterIdleState);
return;
}
PlayMonsterAnimation(MoveTransition, monsterInfo.MoveSpeedRatio);
monsterPathFinding.destination = pathPoints[nextPathPointIndex];
if (monsterPathFinding.reachedDestination)
{
if (nextPathPointIndex == pathPoints.Count - 1)
{
isEscaping = false;
return;
}
nextPathPointIndex++;
SwitchState(MonsterAttackState);
return;
}
}
public virtual void MonsterAttack()
{
isAttacking = true;
if (GamePlaySystem.Instance.PlayerTransform != null)
{
Debug.Log($"Before LookAt: {RotatableBuddyPart.rotation.eulerAngles}");
RotatableBuddyPart.LookAt(GamePlaySystem.Instance.PlayerTransform);
Debug.Log($"After LookAt: {RotatableBuddyPart.rotation.eulerAngles}");
}
}
However, after the code past the Tranform.LookAt( ) part, the its rotates back to its previous moving direction. and shoot its attack. all of it happens within a frame. I checked it by adding Debug log before and after tranform.LookAt() and OnLateUpdate() Unity lifecycle method.
How can I avoid this happen?
I also tried set RVO 's locked to True, it doesn’t work.