Hey!! As always I overcomplicate my study session cause I’m ugly with myself haha. Well, I managed to implement a healtbar, HOWEVER, I’m getting a error message every time the scene reloads and I am, for the moment, unable to solve it (after reload it keeps working but the error messages accumulates Q_Q)… So, no code share for now… Anyway I will keep it until I find a way to fix it… it works… but… not as I want it… I’ll solve it but I am tired now… n_n’/
Having checked with AzuDev first, I’ll post an explanation of how I fixed this problem in my project.
Simply put, there are inherent problems with Godot’s get_tree().reload_current_scene()
. It does not reliably destroy everything from the old scene instance when called, and by extension, it cannot reliably rebuild references to the new object instances in the new scene instance. The error in this particular case stems from the previous level instance’s Path3D being incorrectly referenced in the new level instance, simply because that old reference is not properly updated.
Having run into this problem in my BallChicken project, I built a SceneManager to handle reloading scenes in a different way. It’s a global Autoload scene, so it sits on top of the entire project. In short, when reloading a level, it first kills the current level instance completely, then instantiates a new instance of the same scene. I brought it into this project as a test, and sure enough, no more errors.
Building your own SceneManager is well beyond the scope of this course, but if you feel ambitious and the console errors bother you, this is how to go about fixing them =)