Timer behaviour not starting

0 favourites
  • 5 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • Hi all,

    I have a NPC sprite with animations (walking, idle) and 3 states: idle, left, right. The sprite has a timer behaviour. My goal is to make the NPC walk around (either left or right) for 2 seconds, then choose to either walk again (left or right) or idle for 2 seconds.

    My idea was to start a timer every time the state variable changes to either 0, 1, or 2, (state 0 = idle animation, state 1 = platform left, state 2 = platform right). I've included an image with the code block:

    When the state variable changes, however, the timer is initiated (either walking or waiting) but the countdown doesn't start. Both timers stay at 0/2 seconds:

    Any ideas, anyone?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Because your states aren't changing, the timer keeps getting started, so never progresses. Either add another state, or add the additional check to make sure the timer isn't already running.

  • Thanks very much, blackhornet

    I've added another boolean to check/uncheck whenever the NPC have chosen a state which did the trick!

    I've added an image with the code block, if anyone else who is having brain farts like me :)

    Btw, I am wondering if this can be trimmed / improved in any way?

  • Triggers should always be at the top level - don't bury them under other events. Any for-loops should be done inside the trigger, not out. And the trigger once does nothing - it's already a trigger!

  • Hey blackhornet, thanks for the reply!

    I'm less active during the week (work work work) but will definitely have a look again and see how I can streamline the conditions and actions taking your advice into account and I'll post an update :)

    Thanks again!

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