Error message when domain is not reloaded before each Play Mode

  • A* version: 5.4.6
  • Unity version: 6.3.8f1

Hey there! I’m getting an error message while using the FollowerEntity component, when the domain wasn’t reloaded before the current play mode session. Which happens almost all the time, since my “Project Settings>Editor>When entering Play Mode” is set to “Do not reload Domain or Scene”. Here are the 1st two lines of the error :

“InvalidOperationException: Entity does not exist. You can only access this if the component is active and enabled.
Pathfinding.ECS.FollowerEntityProxy.AssertEntityExists () (at ./Packages/com.arongranberg.astar/Core/AI/FollowerEntityProxy.cs:127)”

I’m calling this code from a very simple function that executes on mouse left click, which sets the IAstarAI.destination to the mouse position on screen. I don’t get any error when using this right after a domain reload (i.e. after script compiling).

My guess is it has something to do with some static member that does not get reset before each Play Mode? In any case, is there a way to fix this other than forcing domain reload on every Play Mode session?

(This being said, the error does not seem to stop the component from doing its job, as my agent still moves toward its destination. But I am cautious about unexpected behavior down the line if I don’t fix this… :smiley:)

Does this happen continually or just like, once? I do also wanna link this in case this is being thrown from a static class: Unity - Scripting API: RuntimeInitializeOnLoadMethodAttribute

1 Like

EDIT : yeah ok, I figured it out, the method that tried to access the object (and its AStar entity) was subscribed to an InputAction.performed, but I never unsubscribed from it, and apparently it IS a static event. Beginner mistake (teehee!). Sorry for wasting your time and thank you so much for your answer, it put me on the right track :grin:

1 Like