I want to play the “die” animation when my players enter this Area2D, but I can’t figure it out. The play_animation function in the player script looks like this:
If you haven’t changed the player script from the Brackey’s tutorial, the player script will change the animation to “idle” on the next frame.
if is_on_floor():
if direction == 0:
animated_sprite.play("idle")
I suggest that you move the death-animation handling code to the player so it’s all in one place. I’m not really a fan of how that particular tutorial does it.
Yeah coming from Java I don’t really like it either but it is my first tutorial on Godot and I was just 100% focused on the engine UI so I didn’t care much about the code.
As I said I can’t test it rn but there is something that caught my attention: if the function call is syntactically correct, why was I not getting the code suggestion as I was writing that line? Is that normal? Am I missing some addon?
I don’t know which function you are talking about, but the code suggestion will only appear if the editor knows what type you’re calling the function on. Godot doesn’t enforce strict variable typing, so it won’t always know what type a variable is.
The function I was talking about was play_animation. When I was trying to call it from killzone.gd it didn’t give me any suggestions while I was writing it, but I figured it out!