time triggers

  • Hi!

    I'm programming the Ai of a basic enemy in a sidescroller.

    the enemy basically stays in a stand postion (looping a "stand" animation) until at a certain moment it triggers a jump animation and it attacks by jumping forward. then it lands and goes again to the stand anim.

    everything works well but I can't find a way of having a perfect control of the moment the jump triggers.

    The ideal way would be to have something triggering when the stand animation begins (after the jump). something like a "time marker". So, it would be like saying: once the marker is set wait X seconds and trigger jump. that way I can add some random seconds or control it easier and not rely on the frames of the stand animation.

    I guess this is what TIMERS are for, but couldn't make it work. i found it on behaviors but don't have a clue how to use it.

  • Hmm why not just use the built in Wait action?

    As the event sheet is run the bots actions will pause at the Wait action for its duration then run rest of actions below (in the bots event.. all events on sheet run basically instantly 60 times a second) which will be the jump attack... use an instance variable to restart its conditions.

  • well, the wait works somehow but still brings a lot of problems

    when the conditions are set the wait is triggered, followed by the attack. But sometimes the conditions change within the time of the wait and the attack triggers when it shouldn't. Let's say: the wait is tirggered (2 seconds) and then the enemy is killed triggering the DIE animation. then, as the wait was already triggered in different conditions the attack will play even when the enemy is in his dying animation. how can I solve this?

  • The timer behavior is easy to understand:

    1) first you must start the timer with an action (start timer, which you can find under the object, that has the timer behavior); give the timer a name/tag.

    2) then there is an event "on timer:", here you use the name you've given your timer and it will trigger when the timer is up

    yeah... guess that's it.

  • [quote:2r2e5914]Let's say: the wait is tirggered (2 seconds) and then the enemy is killed triggering the DIE animation. then, as the wait was already triggered in different conditions the attack will play even when the enemy is in his dying animation. how can I solve this?

    Yeah that would be a problem.

    Only easy way I see around that while still using Wait this way would be to immediately "kill" destroy the instance when enemy is killed and instantly spawn an animation placeholder at its X,Y and run death animation off it.

  • maybe it's better having a couple variables for this action only. just to avoid having a new sprite only for the death animation.

  • Effectively. I tried and it worked. When the wait runs out it doesn't trigger the attack animation but sets a variable to 1.

    then if that variable is 1 and the character is in the right animation it triggers the attack.

    best way I could find.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Simple but effective... one thing I love about Construct2 (and programming in general), there are a dozen or more ways to approach any problem.

  • try this link you might find answer

    https://www.dropbox.com/home/Demos

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