Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Whom |
I’m following this tutorial: Saving games — Godot Engine (3.5) documentation in English
Let’s say I have a node called Enemy with a variable “health”. I save the node’s file name, parent and the health variable etc. just like in the tutorial.
However, I run into problems after I load the save file. The original node is replaced by a new node that has the health value I saved (again, just like in the tutorial). The problem is that the parent still references the old node that does no longer exist: onready var enemy = $Enemy
so I can’t access the new Enemy node from parent. When I try to call a function of the Enemy node, I get this error: Attempt to call function ‘[function]’ in base ‘previously freed instance’ on a null instance.
What is the simplest way to fix this?