Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Judd Gledhill | |
Old Version | Published before Godot 3 was released. |
Hi,
I am attempting my first project with animatedsprites. I generally am putting scenes in a containing Node2D just to hold all of my subnodes. So, I have a “zombie” Node with a single child node that is an animatedsprite and holds 5 different animations.
I am using this code in the top level Node2D (zombie):
extends Node2D
var state = 0 # 0 = not alive, 1 = appearing, 2 = walking, 3 = dieing, 4 = idle
var animator = self.get_child(1) # we will only have a single, animatedsprite
func _ready():
self.set_process(true)
state = 1 # we are alive and should come out of the ground
func _process(delta):
if (state) == 1:
animator.set_current_animation
...
So my question is, when I assign the animatedsprite node in the “get_child” call at the top, how come the editor does not give me the methods on that type at the bottom? The line that says:
animator.set_current_animation
Is not recognized in the editor. I had to type that in and hope that it works. Am I doing something wrong? Should I be casting the ‘animator’ variable to an ‘animatedsprite’ type to get this to work?
Thanks.