Null value error on enemy_path.get_children in

  • In enemy_path is declared but never assigned.
  • the following error occurs in find_best_target when enemy_path.get_children() is called:
    • Cannot call method 'get_children' on a null value

my code looks just like yours. What could be causing this?

I was able to fix it by putting the enemy_path in a group and getting the node that way. However, it’s not clear to me why I had to do it this way when my code looks the same as yours and your seems to work just fine. Could it be that I missed something?

Nice work 10hitCombo and thanks for sharing your solution.

Apologies that this did not get a timely response as for some reason our system only showed it up as tagged today (It may be our tagging system went down)

I wonder if this is related to using a later version of godot as 4.2 has been showing some changes but the issue would suggest that there is a bug in your code. It still could be a version difference however.

Glad you managed to find a solution in any case

1 Like

sorry im a bit late as well, just working through some of the latter lectures.
im wondering if it would be worth checking the turretmanager script, as this is where we are assigning the enemy_path variable of the newly instantiated turrets.

(line 11 in my code here)


also, within the turret manager, would be worth double checking that our @export variable for the path
@export var enemy_path: Path3D is also dragged into the inspector in the base scene so that its assigned.

1 Like

I think this was the issue. I’m basing this off of memory, but I believe I pulled in an instance of the enemy path from a scene other than the one the script was running in, which is why it was null at runtime. Thanks for your replies.

1 Like

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

Privacy & Terms