A problem with Functions and Overlapping Sprite Animations?

Not favoritedFavorited Favorited 0 favourites
From the Asset Store
Cute cartoon girl character with Walk, Jump, and Idle animations for 2D games.
  • Can anyone please help me with this. When the Pineapple is overlapping the Flame, it should trigger a "Cooking" sprite animation and when it's not, it should play the "NotCooking" animation once and then stop. The problem is that the "NotCooking" animation loops, even though looping is not enabled for the sprite. I don't want it to loop.

    Edit: Updated Screenshot

    I've tried many ways to fix it. I tried Trigger Once, For each, Picking UID, Nesting, Else, On animation finished, and I'm not doing it right. I don't know why the animation loops when it's not set to loop.

  • I should add there are multiple Flames and Pineapples on the screen at once, which is why I have the function. I want the Pineapples to interact with the Flames individually.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The issue is that the pineapple is constantly "not cooking" so this event runs every tick. You could track that with an instance variable.

    Pineapple is overlapping flame -> set pineapple.cooking to true

    Pineapple is not overlapping flame & pineapple.cooking = true -> set animation not cooking, set pineapple.cooking = false

    On animation not cooking end -> set animation to default

    Something along those lines

  • Just add "trigger once if true", because right now You have the event running every tick...

  • Can anyone please help me with this. When the Pineapple is overlapping the Flame, it should trigger a "Cooking" sprite animation and when it's not, it should play the "NotCooking" animation once and then stop. The problem is that the "NotCooking" animation loops, even though looping is not enabled for the sprite. I don't want it to loop.

    Edit: Updated Screenshot

    I've tried many ways to fix it. I tried Trigger Once, For each, Picking UID, Nesting, Else, On animation finished, and I'm not doing it right. I don't know why the animation loops when it's not set to loop.

    Hello.

    Please upload *.c3p and I will make it work stably and efficiently with comments.

    It is inconvenient to write in text, and it is not certain that I will be able to explain it in text..

  • The issue is that the pineapple is constantly "not cooking" so this event runs every tick. You could track that with an instance variable.

    Ah! It didn't occur to me the condition was every tick, but I guess it makes sense C3 would check if sprites are overlapping every tick. But why apply that to the actions? I can't find any documentation explaining this. Even the "Is overlapping" description implies only one test is going on. "Object: Select the object to test for overlap with." Shouldn't "test" be plural?

    DiegoM If it's not too much trouble, is there anyway to change the "Is overlapping" description to "Object: Select the object to test every tick for overlap with." This would be very helpful to noobs like me to know every tick is being applied to the actions.

    Pineapple is overlapping flame -> set pineapple.cooking to true

    Pineapple is not overlapping flame & pineapple.cooking = true -> set animation not cooking, set pineapple.cooking = false

    On animation not cooking end -> set animation to default

    Something along those lines

    That works! I felt like I already tried that before, but I must've made some mistake. Then I thought since I was already checking if sprites are overlapping with a function, I could work the sprite animation actions in there too, but it works better separated. I really appreciate your help and I learned something new about the overlapping sprites. Thank you!

    rozpustelnik I tried that, but something about it didn't work and I've long forgotten why. I think maybe because I was using multiple sprite overlaps and it needed to be triggered more than once.

    igortyhon Thanks, but WackyToaster helped me solve the animation issue. Can you help with something else though? I have a function counting how many sprite are overlapping, but once you overlap the sprites and then remove them, the count never goes back to 0. What am I doing wrong?

    OverlapFunction.c3p

    I noticed you like tanks a lot. If you don't mind me asking, were you once a tanker?

  • If it's not too much trouble, is there anyway to change the "Is overlapping" description to "Object: Select the object to test every tick for overlap with."

    This is not how it works. "Is overlapping" is only a condition check. It will be evaluated whenever the event runs. Note that the event sheet runs all events in top-to-bottom order every tick.

    If you place it in the event sheet without any triggers, it will run every tick. If it is placed under a trigger, it will run only when that trigger fires.

  • ...

    igortyhon Thanks, but WackyToaster helped me solve the animation issue. Can you help with something else though? I have a function counting how many sprite are overlapping, but once you overlap the sprites and then remove them, the count never goes back to 0. What am I doing wrong?

    OverlapFunction.c3p

    I noticed you like tanks a lot. If you don't mind me asking, were you once a tanker?

    Construct3 offers many ways to achieve this.

    That’s why I’ve created two versions: one runs and checks continuously, while the other runs only when something happens.

    You can uncomment the desired group to test it.

    fex.net/s/sxn9cmc

    P.S. No, fortunately I’ve never been a tank driver; I draw tanks and make games with them because my son is into it, and he draws them much more often.

  • This is not how it works. "Is overlapping" is only a condition check. It will be evaluated whenever the event runs. Note that the event sheet runs all events in top-to-bottom order every tick.

    If you place it in the event sheet without any triggers, it will run every tick. If it is placed under a trigger, it will run only when that trigger fires.

    But isn't the condition a trigger? Conditions met --> triggers actions? The original question is basically asking why do my animation loop when I don't set them to loop? WackyToaster said it's because "Is overlapping" is every tick. When the condition of objects overlapping is met, it's triggering the animations every tick, yes? If not, the questions remains. Why do the animations loop?

    Construct3 offers many ways to achieve this.

    That’s why I’ve created two versions: one runs and checks continuously, while the other runs only when something happens.

    You can uncomment the desired group to test it.

    https://fex.net/s/sxn9cmc

    I really like variant 2. On collision triggers once and you're checking if the default animation is already playing. I like that way of thinking. I can use that in different ways. Thanks so much for showing me this!

    P.S. No, fortunately I’ve never been a tank driver; I draw tanks and make games with them because my son is into it, and he draws them much more often.

    Ah! That explains the cartoony faces on some of the tanks. You're a good father. My son was into Venus flytraps when he was younger, so I made a really simple game where you could catch flies and drag them to the flytrap and it would eat them. Anyway, I was going to say I was a gunner on a M551 Sheridan tank when I was stationed at NTC (National Training Center), and briefly a gunner on a M3 Bradley (kinda like a tank). Very cool your son is into tanks!

  • Squibble

    Yes, it can be evaluated every tick, but that comes from how the event sheet runs and not from the condition itself. In your case, the animation kept looping because the event was running every tick, so the condition was being checked every tick.

    Anyways, the point was that the description of the condition shouldn’t be changed. This applies to all normal conditions, like “Is visible” as well. They’re just state/comparison checks. They don’t define when they run, only what they check.

  • Squibble

    Yes, it can be evaluated every tick, but that comes from how the event sheet runs and not from the condition itself. In your case, the animation kept looping because the event was running every tick, so the condition was being checked every tick.

    It only loops when the condition is met. So how can you say it's not from the condition itself? Without the condition, the animation doesn't loop.

    Anyways, the point was that the description of the condition shouldn’t be changed. This applies to all normal conditions, like “Is visible” as well. They’re just state/comparison checks. They don’t define when they run, only what they check.

    I respectfully disagree. Take a look at this popup from C3, and explain to me how I'm to deduce that this condition will trigger the following actions attached to it every tick when met?

    There's a lot baked into that condition not explained. The description is lacking. Many descriptions in C3 are lacking. There's a lot of curse of knowledge going on here. The description isn't for people like you that don't need them and already have a deep understanding on how C3 functions. It's for people like me that are trying to learn and understand C3. I wasted hours trying to figure out why my animations were looping before posting here. That creates frustration. I want to save others from that trouble. If the description doesn't fully explain something, then what's the point?

    If the instruction for how to use a grenade only explains that once you pull the pin, the pin comes out, wouldn't you want to also know that pulling the pin triggers the grenade to explode?

  • The eventsheet runs every tick, top to bottom. So every condition in the eventsheet will run every tick.

    The exception are trigger conditions, which only trigger a single time (generally speaking). All trigger conditions have this little green arrow. That's how you deduce this.

    "Is overlapping" is a question you can ask repeatedly: is A overlapping B?

    "On collision" is a definitive singular event, generally described as: Is A overlapping B AND was it not overlapping the previous frame. It will only trigger once, and then never again unless the objects are completely separated and then put together again.

  • Actions will run when all the conditions in the event block are true (if it's an AND event). << This is the most important part of this.

    You only have 1 condition in your block checking every tick

    Is overlaping is a condition, it will return true when the condition is met.

    So it does a collision check whenever you tell it to do it (every tick in your case).

    If it's overlapping every tick then the event will run the actions (because this is the only condition).

    If it's not overlapping it will keep checking of course and returning false so the event will not run the actions (conditions are not met).

    Is overlapping can't specify "every tick" in the description, that's only true in your case not in all cases.

    It can't say "will run actions" because conditions don't run actions, the event run actions when all conditions in the block are true.

    I understand that it's frustrating and the grenade example is funny, but the description is not an instruction, the grenade description should say something like "exploding device" and you choose how to make it explode. Just keep in mind that the conditions are not a single use scenario. They can't define 1 use in the description when it can be used in potentially a hundred different ways.

  • WackyToaster I appreciate the description, but I already know C3 events are read from top to bottom, every tick, which is around 60 times a second. I know there are 3 types of conditions, normal, triggered and looped. And the green arrow indicated a condition is triggered. No issue there. I'm basically just asking for more clarity in the descriptions for new users, and maybe future me. I might stop using this software, come back years from now and try to learn it again. Already happened once...

    Is overlapping can't specify "every tick" in the description, that's only true in your case not in all cases.

    Is there a case where if overlap condition is met, the event actions don't loop? Beside maybe destroy sprite, because it can't keep destroying something that's already been destroyed? That would be some good information to know. Please share.

    It can't say "will run actions" because conditions don't run actions, the event run actions when all conditions in the block are true.

    Never said that.

    I understand that it's frustrating and the grenade example is funny, but the description is not an instruction, the grenade description should say something like "exploding device" and you choose how to make it explode.

    We can talk about that briefly, if you want. What are instructions? It's a description of how to do something. What's a description? Description is a spoken or written representation or account of a person, object, or event. An event is a thing that happens. See how they relate? Here:

    "Object: Select the object to test for overlap with." Is that not an instruction? Is it not describing what's happening? But I digress, because it's not the point I was making. The purpose of the example describing how to use a grenade is that one of the most important parts of what the condition does is left out of the description. "IsOverlapping" loops the actions when the condition is met. There's nothing that implies it's looping the actions when the conditions are met. And I understand the point that if you know everything about how C3 events work, it should be obvious. But this software isn't marketed to users that know everything about the software.

    A better description would be "Object: Select the object to test for overlap, while true, the event's actions are looped." That description tells me all I need to know.

  • Is overlaping does not loop nor trigger actions. It test for overlap with another object like the description say. And returns true or false.

    Is there a case where if overlap condition is met, the event actions don't loop?

    Here's some examples, In this case Is overlapping is allways true because the layout starts with the two sprites already overlaping:

    1- Only run actions one time On start of layout

    2- Only run actions one time every second passes

    3- The sprite doesn't have animations so action will never run.

    4- Will trigger once.

    5- Only run actions when sprite2 is created and also overlapping. Only once.

    6- This event will call a function that will run once every time a blue sprite is destroyed on screen.

    "Object: Select the object to test for overlap, while true, the event's actions are looped."

    That's only applicable to your case, in the examples it will not "loop" the actions even tho is allways overlapping. So that will be a wrong description.

Jump to:
Active Users
There are 0 visitors browsing this topic (0 users and 0 guests)