[Question/bug] confused about how to make FollowerEntity work

Hi, with the new addition of followerEntity now supporting grid graphs I decided to try and use it instead of AIPath, I’m having some issues.

For some reason the character starts rotating freely on the all around, even though I have my grid set to 2D, I had a similar issue with AIPath, which I solved by inheriting and implementing my own CalculateNextRotation method, but I cant do this here as FollowerEntity is sealed.

I tried to just set FollowerEntity.updateRotation to false before setting the destination, but when doing that the character does no move at all anymore, neither the rotation or the position get set.

I should also note that I did disable the gravity checkbox as my game is a topdown 2d and I dont have that.

In addition, when the character does move, it moved in an odd way, almost going in circles, and I have no gizmo showing the path, but that might be related to the rotation.

Another thing I just noticed, all of this happens even though my rigidbody is set to freeze the Z axis, which means the followerEntity some who bypasses it or not using the rigid body at all, unlike the AiPath script

Thanks. There was indeed a bug when grid graphs in 2D. I’ll publish a fix shortly.

The FollowerEntity uses Unity ECS, and cannot interact with rigidbodies directly, however.

How exactly does the Followentity work for 2D?

Could you clarify what you mean?

Hi Aron, thanks for the quick response, I updated but unfortunatly it still happens, I took a quick video showing the issue,

As you can see the rotation values keep changing, and they lean to -90 deg.

BTW, I’m not sure why the class is sealed, I assume it has something with it being ECS, but It would be helpful if we could override some of the functionality like in AIPath, as this is a top-down game, we really dont need any rotation, we set sprites and flip them when needed according to the animation

@aron_granberg please also note that in the video the “rotation speed” property is set to 0, unless in means something else it seems to not be working either.


Yes, the agent will always be aligned with the graph. The “shape” of an agent should be circular in 2D.

You can check out the MecanimBridge2D component. There’s no example scene using it yet (I have one, but it’s not yet in the released package). It uses updateRotation=false to make the agent keep the rotation hidden. The rotation speed of the agent should never be zero, as that will essentially prevent the agent from moving.

Hi, not sure what you mean, as you can see video the agent is not aligned with the graph, the rotation of the graph is 0 while the rotation of the agent is 90.

I also tried setting useRotation to false, it does not (as far as I see) work, the transform rotation still changes.

The graph is aligned with the XY plane, that means it’s rotated as (-90, 0, 0). The agent will also have to be rotated like that.
In a future update I’ll add an orientation option to allow you to use +Y as forward instead of +Z, though (like I’ve done for the other movement scripts).

You mean useRotation on the AIDestinationSetter? (I don’t think there are any other useRotation fields) That’s for making the agent align itself to the target when it reaches it.

Was the rotation speed also zero when you tried this? A zero rotation speed will, as I mentioned, pretty much prevent the agent from moving.

I dont understand, the graph is set to XY, so the why would the rotation be -90?, on the XY plane if you rotate any image on the x or y plane you would get a flat line, exactly like you see in the video, that is also the default view of unity for 2d games, if you go into unity 2d view, place a sprite and rotate it 90deg any the y axis it will “disappear” from view, I did not invent this.

I mean updateRotation, not use rotation, sorry, context switching between frameworks got me here.
Even when calling updateRotation = false, prior to setting the destination, the agent will still have it’s transform rotation updated.

As for needing to rotate the agent not matter what, I can only assume that is required for the new FollowerEntity, as when I inherited from AIPath I made sure to never update the rotation (calculateNextRotation will always return the zero vector) and it works fine so I assumed it would work fine in this case too.

Not sure why but it works now, came back to it after a few days and now the updateRotation does work if set to false.

Thanks @aron_granberg

1 Like