Easy. You create the animations in the editor by creating a SpriteFrames resource and then use logic to choose the animation.
For instance, assuming you are referencing the object from its parent node:
Var anim = $AnimationPlayer
So the name of the AnimationPlayer node, method is play and in parentheses, a string for your animation. There are other methods too, like
Good note: you can also yield to the animation ending before you trigger other logic. For instance, waiting until a animation is done to add points:
# next code here
The Godot docs also explain it well but Davidepesce.com also has some good tutorials to give you a visual reference. Also this link: kidscancode tutorial
Also, good note here: signals connected to the node’s own script are great ways to make transitions between animations and since they connect to its own tree normally, they are easy to instance with little code later if you duplicate them.
Self.connect(“next_frames”, self, “on_next_frames”)
And say when a hit runs you emit your signal:
And then put the code you want to run here:
And as for the warning for when they are done processing: you generally don’t want to call anim.play() more than once in the same function unless you have some way to sequence them. Generally better to separate these into different pieces of logic (and signals are great for this) and not the same piece of code from what I have learned so far. I have a carnival mini-game/whack-a-mole i am working on and i have managed to transition between moles moving up, down, getting hit and being idle all only using the play() function. All you need to do is plug it into the right sequence of logic using the steps above.
Thank you for your long explanation ! Even though this didn’t answer my question , I still learned some new things !
Puzzle objects usually have a fair number of area nodes for interaction (hotspots). For this chest for example, there are : swing lock, key drop, key turn, open lid, close lid, 2 zoom levels, and a zoom out.
The easiest way to activate/deactivate these hotspots in turn, is by using an animationplayer with 1 track for each action.
The problem I’m having, is an issue of timing - even though my code @startup says :
play a ‘default’ animation, -then- setup the default zoom object, Godot always plays the animation -after- the setup of the zoom object.
I suspect it has something to do with the things I mentioned in my original question (the difference betw play() / seek() / advance(), and/or AnimationProcessMode ), but I don’t understand the documentation … So, if someone could explain it in simple terms, I would be very grateful.
That seems easy. Just put this function in the animation for when you load it AND load that zoom box.
Assuming anim is assigned the child $AnimationPlayer:
### then your function or signal or code to load the zoom box
Try that? That should make the loading of the box wait until the animation is done.
SnapCracklins | 2022-03-28 01:58
Thank you. Yes, I understand what you are saying. However, this is a big game and I want to decouple object animations from zoom functionality.
Also, the way I want/need to set all of this up -should- work. There’s nothing strange or complictated about it. It’s just that the animationplayer always starts playing too late (logically).