Fade behavior not activating... for no apparent reason?

This forum is currently in read-only mode.
  • Attached are two cap files that should do almost exactly the same thing, but don't. Load them up, and click the sprites on screen. (For the "fail" one, click multiple times)

    The behavior that SHOULD happen, and does on the "success" file, is that the animation will change to "Dying" and then it will fade away and be destroyed.

    On the "fail" file, however, the dying sprite is triggered, but FADE DOES NOT ACTIVATE.

    Look at the events for the two files. They are -exactly the same-, the ONLY difference being what triggers the event.

    What gives?

  • The fade is activating. 'Start fade' makes it rewind to the beginning of the fade and play from there (when it's opaque). The condition 'Variable less than 0' isn't just true once. It's true all the time. The events are checked once every tick (generally 60-100 times per second), so you're repeating the 'start fade' action over and over again.

    Add the 'Trigger once' system condition below the condition, and it makes it true only once, even when it repeats. It makes it act like a trigger, so it runs just once the first time it's true, instead of every tick.

  • I'm having the same problem, but what I've noticed when I use the Trigger Once condition is that if there are two sprites on the screen (of the same family), only one performs the fade event (or whatever other events), while the other sprite doesn't change at all (animation nor fade). Only until the first sprite is gone is the second sprite able to do what it's supposed to do, but only if it were still "alive" after the first sprite disappeared.

    I tried adding "Trigger Once" as a subevent, but it gave me a similar problem.

  • Can you upload a .cap?

  • Well, if you're talking to me, I tried to isolate the problem in this cap file. If you run it and kill both zombies (within a second or so of each other), only one will fade. In my original game, when I put the Trigger Once in a subevent along with the fade event, both zombies stopped moving and played their "dead" animation, but still only one faded.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The 'Trigger once' means it won't run the event again if it suddenly becomes true for two objects, instead of one. It just still counts as 'true' overall and won't re-trigger. Use a private variable to mark an object as fading (eg. set 'Is Fading' to 1), and change the event to say:

    + Health < 0

    + Is fading = 0

    -> Start fade

    -> Set Is fading to 1


  • That worked. Thanks.

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