Exception when setting FollowerEntity destination to Vector3.positiveInfinity (5.0.4 & 5.0.5)

Hello,

It seems these exceptions are only throw if calls originated from OnDestroy. You can say why do you even setting destination after OnDestroy, it was just a reuse of a method for clearing up stuff for quick prototyping and never looked back since it was working. I now avoid setting destination if the method call originated from OnDestroy and, it solves my problem. This is not a game breaking bug for me, but I wanted to give a log.

For cancelling path, there was an answer by you to another forum post:

which says to set destination field to:
x.destination = new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity);
so I was setting its shorthand Vector3.positiveInfinity.

With v5.0.4 & v5.0.5 and a GridGraph, setting FollowerEntity’s destination to Vector3.positiveInfinity for cancelling pathfinding causes an exception. Before v5, I was using beta 4.3.97 which this was no issue at all with AIPath component.

Line of error:
EnemyEntity line 234 => followerEntity.destination = Vector3.positiveInfinity;

Exception log:

  at Pathfinding.PathTracer.Repair (UnityEngine.Vector3 point, System.Boolean isStart, Pathfinding.PathTracer+RepairQuality quality, Pathfinding.Util.NativeMovementPlane movementPlane, Pathfinding.ITraversalProvider traversalProvider, Pathfinding.Path path, System.Boolean allowCache) [0x001fb] in ./Library/PackageCache/com.arongranberg.astar@5.0.4/Utilities/PathTracer.cs:609 
  at Pathfinding.PathTracer.UpdateStart (UnityEngine.Vector3 position, Pathfinding.PathTracer+RepairQuality quality, Pathfinding.Util.NativeMovementPlane movementPlane, Pathfinding.ITraversalProvider traversalProvider, Pathfinding.Path path) [0x00000] in ./Library/PackageCache/com.arongranberg.astar@5.0.4/Utilities/PathTracer.cs:276 
  at Pathfinding.ECS.RepairPathJob.Execute (Unity.Transforms.LocalTransform& transform, Pathfinding.ECS.MovementState& state, Pathfinding.ECS.AgentCylinderShape& shape, Pathfinding.ECS.AgentMovementPlane& movementPlane, Pathfinding.ECS.DestinationPoint& destination, Pathfinding.ECS.ManagedState managedState, Pathfinding.ECS.MovementSettings& settings, Unity.Collections.NativeList`1[T] nextCornersScratch, Unity.Collections.NativeArray`1[System.Int32]& indicesScratch, Unity.Collections.Allocator allocator, System.Boolean onlyApplyPendingPaths) [0x00042] in ./Library/PackageCache/com.arongranberg.astar@5.0.4/Core/ECS/Jobs/RepairPathJob.cs:103 
  at Pathfinding.FollowerEntity.SetDestination (Unity.Mathematics.float3 destination, Unity.Mathematics.float3 facingDirection) [0x00164] in ./Library/PackageCache/com.arongranberg.astar@5.0.4/Core/AI/FollowerEntity.cs:952 
  at Pathfinding.FollowerEntity.set_destination (UnityEngine.Vector3 value) [0x00000] in ./Library/PackageCache/com.arongranberg.astar@5.0.4/Core/AI/FollowerEntity.cs:871 
  at EnemyEntity.ExitChase () [0x00010] in /Volumes/ExtSSD/UnityProjects/Redacted/Assets/_Game/Scripts/_Project/EnemyEntity.cs:234 
  at EnemyEntity.DeInitialize () [0x00010] in /Volumes/ExtSSD/UnityProjects/Redacted/Assets/_Game/Scripts/_Project/EnemyEntity.cs:156 
  at EnemyEntity.OnDestroy () [0x00000] in /Volumes/ExtSSD/UnityProjects/Redacted/Assets/_Game/Scripts/_Project/EnemyEntity.cs:100

Edit: Another exception case maybe related to above:

I tried setting destination to:

  • followerEntity.destination = some finite position vector

  • followerEntity.SetDestination(new float3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity));

but for both assignments, it gives me this exception below then:

Assertion failure. Value was False
Expected: True
UnityEngine.Assertions.Assert.Fail (System.String message, System.String userMessage) (at /Users/bokken/build/output/unity/unity/Runtime/Export/Assertions/Assert/AssertBase.cs:29)
UnityEngine.Assertions.Assert.IsTrue (System.Boolean condition, System.String message) (at /Users/bokken/build/output/unity/unity/Runtime/Export/Assertions/Assert/AssertBool.cs:20)
Unity.Assertions.Assert.IsTrue (System.Boolean condition, System.String message) (at ./Library/PackageCache/com.unity.entities@1.0.16/Unity.Entities/Stubs/Unity.Assertions/Assert.cs:38)
Unity.Entities.ArchetypeChunkData.GetChangeVersionArrayForType (System.Int32 indexInArchetype) (at ./Library/PackageCache/com.unity.entities@1.0.16/Unity.Entities/Types/ArchetypeChunkData.cs:268)
Unity.Entities.ArchetypeChunkData.SetChangeVersion (System.Int32 indexInArchetype, System.Int32 chunkIndex, System.UInt32 version) (at ./Library/PackageCache/com.unity.entities@1.0.16/Unity.Entities/Types/ArchetypeChunkData.cs:287)
Unity.Entities.Chunk.SetChangeVersion (System.Int32 indexInArchetype, System.UInt32 version) (at ./Library/PackageCache/com.unity.entities@1.0.16/Unity.Entities/Types/Chunk.cs:88)
Unity.Entities.ChunkDataUtility.GetComponentDataWithTypeRW (Unity.Entities.Chunk* chunk, Unity.Entities.Archetype* archetype, System.Int32 baseEntityIndex, Unity.Entities.TypeIndex typeIndex, System.UInt32 globalSystemVersion, Unity.Entities.LookupCache& lookupCache) (at ./Library/PackageCache/com.unity.entities@1.0.16/Unity.Entities/ChunkDataUtility.cs:168)
Unity.Entities.ArchetypeChunk.GetRequiredComponentDataPtrRW[T] (Unity.Entities.ComponentTypeHandle`1[T]& typeHandle) (at ./Library/PackageCache/com.unity.entities@1.0.16/Unity.Entities/Iterators/ArchetypeChunkArray.cs:1654)
Pathfinding.FollowerEntity.SetDestination (Unity.Mathematics.float3 destination, Unity.Mathematics.float3 facingDirection) (at ./Library/PackageCache/com.arongranberg.astar@5.0.5/Core/AI/FollowerEntity.cs:932)
Pathfinding.FollowerEntity.set_destination (UnityEngine.Vector3 value) (at ./Library/PackageCache/com.arongranberg.astar@5.0.5/Core/AI/FollowerEntity.cs:871)
EnemyEntity.ExitChase () (at Assets/_Game/Scripts/_Project/EnemyEntity.cs:234)
EnemyEntity.DeInitialize () (at Assets/_Game/Scripts/_Project/EnemyEntity.cs:156)
EnemyEntity.OnDestroy () (at Assets/_Game/Scripts/_Project/EnemyEntity.cs:100)

OnDestroy triggers this stack trace at first, so to identify cause I checked if:

- followerEntity != null
- followerEntity.entity != null
- followerEntity.hasEntity
- World.DefaultGameObjectInjectionWorld != null
- World.DefaultGameObjectInjectionWorld.EntityManager != null

yet no chance. These are all returns and logs true. It still throws an exception.

Hope these logs can help you to identify the issue. Besides huge improvements in v5, FollowerEntity is a great addition, keep up the good work!

Hi

I cannot replicate this :confused:

Would you mind trying to upgrade your entities package to the latest version?

I cannot edit original post but, now I check the first exception codeview seems omitted first line, which was:
ArgumentException: Position must be a finite vector

I am on 2023.2.22f1 (Latest 2022LTS) and Entities 1.0.16 (Latest for 2022LTS)

Hope this helps. I will try to send you a reproduced environment as well.

1 Like

That would be amazing.