Godot Version
4.6.2
Question
i am working on my first top down game I’m also following a tutorial on YouTube so it doesn’t cover any errors. the issue is that it was working just fine until i added a canvas layer with a control child node and that has a label child node. if there is an easier way of doing this that won’t give me this error or if i am writing something wrong i would have no idea. I tried to learn from the lessons Godot has but they make zero sense to me. I am receiving the error
“_physics_process: Invalid access to property or key “global_position” on a baseobject of type ‘NIL’”
the correlating code its showing for is
“var direction=(player.global_position-global_position).normalized()”
its within a function to spawn enemies:
func _physics_process(_delta: float) → void:
#spawn an enemy
var direction=(player.global_position-global_position).normalized()
velocity=direction*SPEED
move_and_slide()