0 votes

I'm working on my very first Godot project. Just a simple 2D game in GDscript.

I have a node for my player character with an AnimationPlayer attached. What I'm trying to do is to get one animation to play one time after a condition is met (in this case, pressing a key) before switching back to the player character's default animation, which I've set up to fire with the state WALK. This is so I can make attacking and jumping work.

This should be fairly simple to set up with a Call Method Track on the animation in question, but unfortunately I can't find any of my functions on the list it gives me when I click "Insert Key", even after saving my project.

I've tried moving the declaration of the function around to different parts of my player script, and I've ensured that I've selected the Player node when I added the Method Track. I even tried just adding in empty functions and then saving to see if they would appear, e.g.

func jimmy_bob():
    pass

But no matter what, none of the functions that I have created in my scripting will appear when I add them as a Key in the animation track. What have I done wrong?

Godot version 3.3
in Engine by (20 points)

English isn't my native language(so maybe this is the problem) but it isn't clear where is the problem and the lack of the relative code doesn't help.
You mentioned that you click "Insert key". But what is this? Is a button? Did you have connect the "pressed" signal of that button(and how you did it)? You did it and you tried there to put your function? You also posted the function "jimmy_bob()". Have you put that function inside the "pressed" function and it doesn't called? And how you know that it doesn't? What you expect to see? You haven't put nothing on that function so you will not see any output.

adding a Call Method Track to the animation:

adding a Call Method Track to the animation

making sure the player node is selected:

selecting the player node

adding a key onto the track:

adding a new key onto the track

the function jimmy_bob() not appearing, even though it is in the script and the project has been saved:

the function jimmy_bob() not appearing, even though it is in the script and the project has been saved

I'm quite new to godot and I haven't use this way on animator player, so I misunderstood. Now is clear what you try to do though. Maybe someone who has use it can help more.
But I show the documentation and I think that you cannot add a custom method. Also I tried it and added a method from the list(printtreepretty). I already had an animation player and an animation on a label. I added the track method on a key and the method called as expected every time on the specified frame. This method not appearing on my script and seems that there is no way to add it to a script.

1 Answer

+2 votes

I've figured out the solution: closing and re-opening Godot. Hope this helps people in future.

by (20 points)

It has helped me, I was having the exact same issue; thanks @outlandish99

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.