[ECS] Follower entity rotation on XY plane

  • A* version: 5.3.3
  • Unity version: 6000.0.31f1

Hello,

I am using the FollowerEntity component as a base for pure ECS movement (I used the authoring script from this thread) in conjunction with an XY-axis 2D grid graph.

The problem I’m facing is that my entities are being automatically rotated perpendicularly to the graph, which is not the desired behavior - I want them to retain their original rotation, as in my prefab. Is there a way to disable automatic rotation for pure ECS-based agents?

I know in a MonoBehaviour component this can be done by setting RotationSync, but it seems like this isn’t possible through ECS components. Am I correct?

If disabling auto-rotation isn’t possible, would writing my own locomotion system in ECS be the best approach?

Thanks in advance!

Hmm, gonna have to ask @aron_granberg about this one. I do remember some previous talk about pure ECS and rotation but I cannot recall where that conversation took place. Will tag him and let him know about this question :+1:

1 Like

Hi

The rotation sync property is represented on the entity as the SyncRotationWithTransform component being either there or not there.

@aron_granberg If im not mistaken, the SyncRotationWithTransform just affects the sync from entity to it’s connected gameobject. I think what @Micuda is asking is on the entity itself (if entities only)?

I fiddled with something like this awhile ago on a pure ECS project. I think the solution was to reset the rotation every frame in one of the components. I don’t remember if it was LocalTransform, or one of the Astar ones like MovementControl. One of them works without breaking agent turning. Once you figure out the one that works you could modify the Astar code so that there is a flag to prevent changing it.

2 Likes

Hey, thanks for stepping in, that’s exactly what I meant, SyncRotationWithTransform makes no change to the entity behaviour in terms of rotation, it definitely needs to be done differently.

Unfortunately I switched to another solution since last time, so I cannot test your suggested way, but I guess rotation reset (ideally in custom correctly ordered system) should work, although I would expect this option to be included on some of the follower entity’s components - looks like it’s not currently the case though.

1 Like

Hi

Sorry. There’s no way to completely disable the entity’s rotation at the moment. The agent needs the rotation for its movement behavior.
Is this purely for rendering? Could you create a separate entity that just follows the position of the agent, but doesn’t copy the rotation?