2D Follower Entity constantly changing Z position

Noticed many had this issue in the past as well, but it’s happening with the new Follower Entity component now.

Pretty easy to replicate:

  • Create an empty game object
  • Add the Follower Entity component to it and set the Orientation to YAxisForward
  • Add the AIDestinationSetting component to it and set it to any target on your 2d plane.

Run the game and observe your agent’s Z position constantly changing anywhere from -10 to +10 even though it starts a 0 and its target is also at 0.

An old post said to add a Rigidbody 2D to it with 0 Gravity Scale, but that didn’t make any difference either.

Are you sure it’s changing that much? It’s not just displaying a tiny floating point value using scientific notation?

Yes, it is anywhere from -10 to 10 and constantly updating, even when it has reached the end of the path and isn’t moving on the X/Y axis anymore.

Other reports of this. The last link mentions adding a RigidBody2D with gravity scale at 0, but that does nothing either.

Hi

I cannot replicate this, I’m afraid.

Do you have a video of this issue that you could upload? Showing both the scene view (with the graph and agent) and the inspector.

It’s very easily replicated by creating a new 2d project and following the steps in my OP. I just created a basic project that still has this issue, would you like me to upload it somewhere?

It happens even without an AIDestinationSetter and no movement. If I remove the AstarPath component from my scene, it no longer does this, so it’s tied to that somehow.

Please do.

BTW. I assume you also have a 2d graph in the scene?

Yup, it’s a 2D Graph. Just DM’d you it.

Was my example able to help you?

It looks like you have gravity enabled. That will make the agent fall down, and then snap back to the navmesh surface when it gets too far away from it.

In the next update, I’ll make sure that gravity is automatically disabled when in 2D mode.

I actually do have gravity turned off. Maybe it didn’t come through in the export, but the issue still remains, so I’m not sure that is the cause of it.

Also, it’s not falling and snapping back as you mentioned. The Z value fluctuates from negative to positive values.

Were you able to run my project and reproduce it yourself?

5.2.2 fixed the issue! Thank you so much for looking into this.