Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Drai3Seltor |
Hi, I am trying to animate a sprite, so i set few animation, but when I call the function
if Input.is_action_pressed("move_up"):
vel.y -= 1
facingDir = Vector2(0, -1)
$AnimationPlayer.play("move_up")
this error shows up
E 0:00:02.596 get_node: (Node not found: “AnimationPlayer” (relative to “/root/Player”).)
<Errore C++> Condition “!node” is true. Returned: nullptr
<Sorgente C++>scene/main/node.cpp:1325 @ get_node()
Player.gd:20 @ _physics_process()
now, I have the AnimationPlayer directly under the Player node, and also from script it autocomplete. I do not really know what I am doing wrong
If the script is attached to the Player node and the AnimationPlayer is a child of the Player, the code should run, unless you somehow delete the node on runtime. Does get_children() return a list including the AnimationPlayer?
skysphr | 2022-03-27 14:13
Maybe you are reparenting it at runtime somewhere in your code.
magicalogic | 2022-03-27 19:58
The same has happened to me a few times.
Change node name
ramazan | 2022-03-28 08:16