[Solved] Different animations depending on amount of items collected


I need some help with an animation in my game. My player is supposed to collect 5 items, when one or more is collected and the player is close to my (let’s call it checkpoint) I want it to activate different animations of the checkpoint depending on how many items they’ve collected.I have created seperate animations for each amount of items collected. So far I have managed to activate the first animation when colleting one item bit I can’t figure out how to activate the rest. For clarification. When 1 item is collected I want animation 1 to play when player touches the checkpoint. When 3 items is collected I want animation 1,2 & 3 to play. Hope anyone understands what I mean. Would be super greatful if someone could help me!

Player is in collision with ‘item’ change the value of scene variable (ItemsCollected) add 1
Change the animation of ‘checkpoint’ set to SceneVariable(ItemsCollected)

Keep track of how many items have been collected in a scene variable (ItemsCollected).

Then use something like the following to play each animation in sequence, up to the value of ItemsCollected :


Thank you so much for the help! You’re the best!

1 Like

Hi again MrMen,

I managed to get the animation to work, but unfortunatley not in sequence which would look the best for the game. I tried putting it in like the Picture you sent, bit only the first animation on my checkpoint starts playing. Not sure what I am doing wrong. I’ll try to upload some screenshots. In my game the variable is called “Minnen” and my checkpoint is called “Minneactivation”. Would be super greatful if you could have a look. Thank you!

This is the one I’m currently using that works, bit it doesn’t looks good when all the animations activates at the same time.


is not the same as

  1. You’ve indented the second event. This means is only gets processed when the first event is actioned, and that’s just once, when Majken and Minneactivation collide for the first time. Move the second event so it’s in line with the first one.

  2. The order of actions is important. You need to set the animation first, then play it. Otherwise the set animation is the last action, and the playing is overridden.

Thank you for the fast reply, I truly appreciate it.
Yes, sorry I understand. I did as in your original screenshot in the beginning but I’ve been messig around with it all day and forgot to change it back before I took the screenshot. I’m sending a new screenshot. When it’s like this only the first animation activates and nothing else is happening. Am I still doing it wrong?

What is the value of MinnenCollected before Minneaction is reached and again before the animation second animation is supposed to be played? Do you reset it somewhere before the animations have a chance to finish playing?

You can use the output to console action, and then check the output in the debugger.

The player is supposed to collect five items on each scene. The Value collected when first reaching the “checkpoint” depends on which scene you are on and on which route you take. Sometime the player has collected three items and then three flowers on the “minneactivation”/checkpoint Will activate to show the player that it has collected three out of five items. If that makes sense? The Value only resets when the player starts a new scene.

Yep, I understand that and what you’re trying to achieve. My line of thought is that the animations don’t fire because one of the conditons isn’t met. So it’s a matter of working out which one. I’m going with the assumption that it’s not a problem with the animation finished condition (though making assumptions isn’t a healthy thing to do), and so I’m focusing on whether the other condition isnt being met (for whatever reason).

It’s pretty much a process of elimination and reducng the list of potential causes down to 1.

And that’s why I’m asking about the value of MinnenCollected. So if that’s correct, the it’ll be the animation finished condition that’s not being met (and my assumption will be incorrect :slight_smile: ).

I think the other thing to check is that MinnenCollected is a scene variable (and not a global one), and the spelling and case are the same (GDevelop is case sensitive)

I see, I understand that it’s really hard trying to figure out what’s wrong via a forum and not seeing the whole thing in person. Thank you for taking the time.

I have checked the Spelling and everything looks correct. It is also a scene variable so that doesn’t seem to be the problem either.

When I use this setup, everything works as intendend, except that all animations trigger simultaneously.

Ok, and what is it’s value when Majken is in collision with Minneactivation? You’ll need to put the variable value to a temporary text obejct or output it to console to see this.

I see in your last screen snip that you are using the variable Minnen, where as in the previous one you are using MinnenCollected. Is there a reason for using a different variable?

Oh, that was a misunderstanding from my side. Changed it now and now the animations are playing. But now they start each time I collect a new item even if I’m not close to “minneactivation” and also the animation replays each time I’m in collision with “minneactivation”. The goes up each time i collect my item so that seems to work like it should.

Which version of the events are you using - the one I suggested, or the latest one you posted?

The one you suggested. Now when I have collected all items the animation plays like I wanted to which is great. But I only want it to play when she touches the “minneactivation” and preferably that it doesn’t replay from the beginning each time she touches it (But if that’s too much I think I could be fine with it.)

Ok, you may need to change the second event conditions and add a check the animation number is greater than 0 (the first condition in the snip below) :


And then remember to reset the animation of Minneactivation to 0 afterwards .
Ignore that - I guess you’d want to leave it at the last animation.

What happens now is when I collect the first two items everything work perfectly. The animation doesn’t play until I’m in collision with “minneactivation”. But when I proceed and collect the rest the animations start without the player being close to “minneactivation”. Any idea why that is happening? And also the animation still replays each time I’m in collision with it.

Not straight off. Can you give a screen snip of the events around collecting the items and the Minneactivation collision?

Yes, because when Majkan collides with Minneactivation, the animation starts from 1. That seems to be pretty much what you requested the first post.

But, if you want the animations to progress from the last animation as more items are collected, then that’d be an easy change to the current events.

I added “In collision” to the second line and that seemed to fix the issue with the “minneactivation” starting without the player being close to it.

Yes I think it would look better if the animation started from the last animation as more items are collected.

To achieve that, take away that collision you added in the second event, and to the first event add the condition The number of the animation of Minneactivation = 0. That should be all it needs.