problem with reloading or changing the scene from code

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bobidabob

I have a pathfinding system set up like in this article, but when I change or reload the scene I get this error:

Invalid get index ‘scent_trail’ (on base: ‘previously freed instance’).

any help would be appreciated, thanks

:bust_in_silhouette: Reply From: Inces

I am not going to read whole article just to answer this question, but I can guess what is going on
your persistent node is dependent on reference to non-persistent node. You remove one scene, so the one that stays no longer can find a reference to it. There are few options to solve this issue :

  1. Release hard dependencies, keeping all shared data related to navigation in Autoload/high scope script
  2. Do not remove a scene responsible for navigation, reset its contents manually
  3. Make no node persistent, queue free both a scene and a player, so the new instance of player will become dependent on a new instance of a level