Barbarian Blaster projectile on_area_entered

Just got to the part of the course where the projectiles subtract health from the enemies. As far as I can see I have the scripts identical to the courses but I am getting an error:
Invalid get index ‘current_health’ (on base: ‘PathFollow3d (BaseLevel.tscn::GDScript_kyhrt)’).

It only gives the error when I add the area.get_parent().current_health -= 25 line and run the game.

here is the project so far:
Barbarian Blaster

Thank you for any help you can provide.

Sure, I’m happy to take a look, but your uploaded project is access-restricted.

Sorry about that, I think it’s unrestricted now.

1 Like

I got it - that was a tricky one! Your syntax is fine, but your 5 hard instances of the Enemy scene are not being updated correctly - they don’t reflect the changes you are making to the Enemy scene. This is not unexpected, Godot will do this occasionally, but it can be difficult to diagnose because error messages won’t help you (much. In the end, that’s still what got me to the solution)!

To fix your project, delete Enemies 1 through 5, then instantiate replacement Enemies for BaseLevel’s Path3D node as you see fit. That’s all - everything works on my end.

To avoid this issue in future, try to avoid creating something in a main scene and then using Save Branch To Scene; instead, create a new object scene, save it, and instantiate it in the main scene when you’re ready. Although Bram doesn’t really follow this methodology himself, I’ve personally noticed that it all but completely eliminates this particular type of problem. If it should happen anyway, the solution is still to delete all affected hard instances and reinstantiate them, just like here. Have fun!

2 Likes

I will give that a go! Thank you for the help. That is definitely not something I would have ever looked at but I will now remember if I ever see it again lol.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms