Time based animation toggle?

0 favourites
  • 2 posts
From the Asset Store
Advanced inventory mechanics for your RPG game (Array-based). Take Items, split them, pick up them, read the description
  • I see sometimes animation snubs off and toggles... meaning there could be a race condition happening.

    So wondering if there is a better way to do this.. that will ensure that the timing race doesnt happen between these two animations?

    "Default" has no image

    "LazerON" has a lazer beam animating glow

    <img src="https://dl.dropboxusercontent.com/u/48735785/Construct2_Issues/toggling-lazer.png" border="0" />

    Thanks :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you step back a minute, your code is saying:

    every 5 seconds turn the laser on and every 5 seconds turn the laser off

    The race condition is pretty self evident.

    There's also the case where the laser goes out of range, but comes back in again within 5 seconds. You are still going to have the previous '5 second Wait to turn off' code sitting around, so if the laser is turned on again, it's going to be turned off in less than 5 seconds.

    I'd recommend using the new timer object over Wait. People are constantly abusing Wait. With a Timer you can control when to stop a timer, but you can't stop a Wait (without a bunch of extra work, which Timer is doing for you).

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