I tried adding navigation to the NPC characters in null using NavigationAgent2D
and ran into a weird problem where _physics_process(_delta)
was never being called whenever I had a value for target_position
that I wanted to use. As it turns out, I forgot to use call_deferred("actor_setup")
when waiting one physics frame in _ready()
.
Incorrect usage of await in
_ready()
:In this example,
_physics_process
will never be called becauseawait
was called directly from_ready()
Correct usage of await in
_ready()
:To
await
in a ready, you must usecall_deferred()
so that the await happens after_ready
is done.
Not sure why awaiting in _ready()
causes this problem. It might be worthwhile looking into that later.