Using FollowerEntity from Astar Pathfinding Project with Movement Pack

Pixelsquid

New member
Getting lots of errors when using some of the movement pack integration with Astar. Some work fine like Wander, but others like Flee throw ECS based errors. Does the movement pack not support Astar's FollowerEntity pathfinder? Thought that with the upgrade to ECS it would

InvalidOperationException: Structural changes are not allowed while iterating over entities. Please use EntityCommandBuffer instead.
 
What is the full stack trace of the error? I haven't used the FollowerEntity pathfinder but if it implements the IAstarAI interface then it should work.
 
Code:
InvalidOperationException: Structural changes are not allowed while iterating over entities. Please use EntityCommandBuffer instead.
Unity.Entities.EntityDataAccess.CheckIsStructuralChange () (at ./Library/PackageCache/com.unity.entities@b749ad90954b/Unity.Entities/EntityDataAccess.cs:336)
Unity.Entities.EntityDataAccess.BeforeStructuralChange () (at ./Library/PackageCache/com.unity.entities@b749ad90954b/Unity.Entities/EntityDataAccess.cs:410)
Unity.Entities.EntityDataAccess.BeginStructuralChanges () (at ./Library/PackageCache/com.unity.entities@b749ad90954b/Unity.Entities/EntityDataAccess.cs:420)
Unity.Entities.EntityManager.RemoveComponent (Unity.Entities.Entity entity, Unity.Entities.ComponentType componentType) (at ./Library/PackageCache/com.unity.entities@b749ad90954b/Unity.Entities/EntityManager.cs:2178)
Unity.Entities.EntityManager.RemoveComponent[T] (Unity.Entities.Entity entity) (at ./Library/PackageCache/com.unity.entities@b749ad90954b/Unity.Entities/EntityManager.cs:2340)
Pathfinding.FollowerEntity.ToggleComponent[T] (Unity.Entities.Entity entity, System.Boolean enabled, System.Boolean mustExist) (at ./Packages/com.arongranberg.astar/Core/AI/FollowerEntity.cs:1404)
Pathfinding.FollowerEntity.set_updateRotation (System.Boolean value) (at ./Packages/com.arongranberg.astar/Core/AI/FollowerEntity.cs:1370)
Opsive.BehaviorDesigner.AddOns.MovementPack.Runtime.Tasks.AstarAIPathfinder.UpdateRotation (System.Boolean update) (at Assets/Opsive/BehaviorDesigner/Add-Ons/MovementPack/Integrations/AstarPathfindingProject/AstarAIPathfinder.cs:60)
Opsive.BehaviorDesigner.AddOns.MovementPack.Runtime.Tasks.AstarAIPathfinder.OnEnd () (at Assets/Opsive/BehaviorDesigner/Add-Ons/MovementPack/Integrations/AstarPathfindingProject/AstarAIPathfinder.cs:134)
Opsive.BehaviorDesigner.AddOns.MovementPack.Runtime.Tasks.MovementBase.OnEnd () (at Assets/Opsive/BehaviorDesigner/Add-Ons/MovementPack/Scripts/Tasks/MovementBase.cs:96)
Opsive.BehaviorDesigner.Runtime.Tasks.StackedTask.OnEnd () (at ./Packages/com.opsive.behaviordesigner/Runtime/Tasks/StackedTask.cs:266)
Opsive.BehaviorDesigner.Runtime.Systems.TaskObjectSystem.OnUpdate (Unity.Entities.SystemState& state) (at ./Packages/com.opsive.behaviordesigner/Runtime/Systems/TaskObjectSystem.cs:107)
Opsive.BehaviorDesigner.Runtime.Systems.TaskObjectSystem.__codegen__OnUpdate (System.IntPtr self, System.IntPtr state) (at <fddd6e200d1a49acb74d3603749d841c>:0)
Unity.Entities.SystemBaseRegistry+<>c__DisplayClass9_0.<SelectBurstFn>b__0 (System.IntPtr system, System.IntPtr state) (at ./Library/PackageCache/com.unity.entities@b749ad90954b/Unity.Entities/SystemBaseRegistry.cs:249)
UnityEngine.Debug:LogException(Exception)
Unity.Debug:LogException(Exception) (at ./Library/PackageCache/com.unity.entities@b749ad90954b/Unity.Entities/Stubs/Unity/Debug.cs:17)
Unity.Entities.<>c__DisplayClass9_0:<SelectBurstFn>b__0(IntPtr, IntPtr) (at ./Library/PackageCache/com.unity.entities@b749ad90954b/Unity.Entities/SystemBaseRegistry.cs:253)
Unity.Entities.UnmanagedUpdate_0000167D$BurstDirectCall:wrapper_native_indirect_0000013509AD6C48(IntPtr&, Void*)
Unity.Entities.UnmanagedUpdate_0000167D$BurstDirectCall:Invoke(Void*)
Unity.Entities.WorldUnmanagedImpl:UnmanagedUpdate(Void*)
Unity.Entities.WorldUnmanagedImpl:UpdateSystem(SystemHandle) (at ./Library/PackageCache/com.unity.entities@b749ad90954b/Unity.Entities/WorldUnmanaged.cs:891)
Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at ./Library/PackageCache/com.unity.entities@b749ad90954b/Unity.Entities/ComponentSystemGroup.cs:717)
Unity.Entities.ComponentSystemGroup:OnUpdate() (at ./Library/PackageCache/com.unity.entities@b749ad90954b/Unity.Entities/ComponentSystemGroup.cs:681)
Opsive.BehaviorDesigner.Runtime.Groups.TraversalTaskSystemGroup:OnUpdate() (at ./Packages/com.opsive.behaviordesigner/Runtime/Groups/TaskSystemGroup.cs:33)
Unity.Entities.SystemBase:Update() (at ./Library/PackageCache/com.unity.entities@b749ad90954b/Unity.Entities/SystemBase.cs:418)
Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at ./Library/PackageCache/com.unity.entities@b749ad90954b/Unity.Entities/ComponentSystemGroup.cs:723)
Unity.Entities.ComponentSystemGroup:OnUpdate() (at ./Library/PackageCache/com.unity.entities@b749ad90954b/Unity.Entities/ComponentSystemGroup.cs:681)
Opsive.BehaviorDesigner.Runtime.Groups.TraversalSystemGroup:OnUpdate() (at ./Packages/com.opsive.behaviordesigner/Runtime/Groups/TraversalSystemGroup.cs:43)
Unity.Entities.SystemBase:Update() (at ./Library/PackageCache/com.unity.entities@b749ad90954b/Unity.Entities/SystemBase.cs:418)
Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at ./Library/PackageCache/com.unity.entities@b749ad90954b/Unity.Entities/ComponentSystemGroup.cs:723)
Unity.Entities.ComponentSystemGroup:OnUpdate() (at ./Library/PackageCache/com.unity.entities@b749ad90954b/Unity.Entities/ComponentSystemGroup.cs:681)
Opsive.BehaviorDesigner.Runtime.Groups.BehaviorTreeSystemGroup:OnUpdate() (at ./Packages/com.opsive.behaviordesigner/Runtime/Groups/BehaviorTreeSystemGroup.cs:59)
Unity.Entities.SystemBase:Update() (at ./Library/PackageCache/com.unity.entities@b749ad90954b/Unity.Entities/SystemBase.cs:418)
Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at ./Library/PackageCache/com.unity.entities@b749ad90954b/Unity.Entities/ComponentSystemGroup.cs:723)
Unity.Entities.ComponentSystemGroup:OnUpdate() (at ./Library/PackageCache/com.unity.entities@b749ad90954b/Unity.Entities/ComponentSystemGroup.cs:681)
Unity.Entities.SystemBase:Update() (at ./Library/PackageCache/com.unity.entities@b749ad90954b/Unity.Entities/SystemBase.cs:418)
Unity.Entities.DummyDelegateWrapper:TriggerUpdate() (at ./Library/PackageCache/com.unity.entities@b749ad90954b/Unity.Entities/ScriptBehaviourUpdateOrder.cs:523)
 
Pretty sure its implementing AstarAI, it works for Wander at least. That error is from the Flee Task. The Target is another GameObject with the same prefab, but it throws the same error if the target is just some generic object too
 
It looks like that error is coming from A*. When the update rotation is set the FollowerEntity is changing the component structure. Ideally and Entity Command Buffer should be used but that code is within A*. Can you report the bug to the A* developer?
 
I'm facing the same issue. Here is the response from the A* team. Link
Since I don't have much background knowledge about ECS yet, I find it a bit confusing.
 
The Movement Pack tasks are not setup to use the Entity workflow. I have it on my list to add support for that but first need to get Formations and Tactical out.
 
The Movement Pack tasks are not setup to use the Entity workflow. I have it on my list to add support for that but first need to get Formations and Tactical out.
Hi, you are not responding in discord for 5 days, I had to register here, maybe there is better support. What about FollowerEntity support? I understand you released all these packages, is it available or not?
 
Official support is provided by the forum so it's good that you made it here.

With that said, I have not had a change to look at FollowerEntity yet.
 
The A* integration has been updated and it now supports FollowerEntity.

The problem with FollowerEntity relates to A* structural changes when Behavior Designer is looping over the entities. This only happens when UpdateRotation is set. I've updated the integration to not set the Update Rotation value if you are using the FollowerEntity. For right now you will need to update the rotation outside of the task, but I will get in contact with the A* developer to see what we can do to support this. I believe this will cover the vast number of use cases for FollowerEntity though!
 
The A* integration has been updated and it now supports FollowerEntity.

The problem with FollowerEntity relates to A* structural changes when Behavior Designer is looping over the entities. This only happens when UpdateRotation is set. I've updated the integration to not set the Update Rotation value if you are using the FollowerEntity. For right now you will need to update the rotation outside of the task, but I will get in contact with the A* developer to see what we can do to support this. I believe this will cover the vast number of use cases for FollowerEntity though!
hi , i reinstall , but i think you forgot core scripts, only demo files include on package
 
For right now you will need to update the rotation outside of the task
Can you clarify this point for me please? Are you saying we should set the .updateRotation of the FollowerEntity outside of the Movement actions (such as Seek) as separate actions, or that we should set it outside the Behavior Tree entirely?

I've tried the former, having a standalone "ToggleAgentRotation : Action", but I get the same error (InvalidOperationException: Structural changes are not allowed while iterating over entities. Please use EntityCommandBuffer instead.)
 
Back
Top