|Topic was automatically imported from the old Question2Answer platform.
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.
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?
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.
dancaer69 | 2021-05-09 08:29
adding a Call Method Track to the animation:
making sure the player node is selected:
adding a key onto the track:
the function jimmy_bob() not appearing, even though it is in the script and the project has been saved:
outlandish99 | 2021-05-09 09:53
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(print_tree_pretty). 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.
dancaer69 | 2021-05-09 10:54