I am new in C# and I am doing some practice in Godot. I have a "Mob" node (KinematicBody) and it's child, a "Sprite" node (Spatial). In the _Ready() method I get the "Sprite" object, that is "Mob's" child:
public Node sprite;
public override void _Ready()
{
sprite = GetNode("Sprite");
GD.Print(sprite); // All good so far. It gets the correct object.
}
But, when I try to use a method from "Sprite" at another part of the code, it results in error.
The call code line:
sprite.SetAnimation(state, face);
The method I am trying to call from "Sprite:
public void SetAnimation(string state, string face)
{
GD.Print(state + "_" + face); // Just to test if it works.
}
The error I get:
'Node' does not contain a definition for 'SetAnimation' and no accessible extension method 'SetAnimation' accepting a first argument of type 'Node' could be found (are you missing a using directive or an assembly reference?)
What am I doing wrong?