AIPath returns a different velocity when canMove is false

  • A* version: [5.3.7]
  • Unity version: [6000.1.15f1]

Hi,
AIPath does not return correct velocity (zero) when canMove is false.
I changed the OnUpdate of AIBase as follows:

  	if (canMove) {
  		MovementUpdate(dt, out var nextPosition, out var nextRotation);
  		UnityEngine.Profiling.Profiler.BeginSample("Finalize");
  		FinalizeMovement(nextPosition, nextRotation);
  		UnityEngine.Profiling.Profiler.EndSample();
  	}
  	else
  	{
  		// fix
  		// Always update location history regardless of canMove
  		UpdateVelocity();
  	}

Aron knows about this- I believe it’s a “working as intended” case here. I wouldn’t know why/if there are ramifications to always updating velocity but it’s known and come up before so I’d wager there are repercussions to it.

Thanks for posting anyways, I’m sure this will help folks out in the future via search.

1 Like

I’ll rename canMove to simulateMovement in the next update to clarify what that field is for.
Turning it off will completely disable all movement calculations. It’s often used when overriding movement calculations yourself.

I’d recommend using ai.isStopped instead.

1 Like