"Wait" in Enemy Attack Phase

0 favourites
  • 6 posts
From the Asset Store
Moles Attack game assets for 2D whack a mole smash and hit action fun game.
  • I have tried so many combinations for a week now, and this (simple?) action will not behave for me.

    Fighting game, 1 player and 1 enemy. The following is simplified to show the problem. Sprite animations are in "quotes".

    GAMEPLAY

    While in "Idle" (not moving) pose, the enemy should "Attack" once every 4 seconds. This works fine.

    If player attacks enemy during "Idle", the enemy should "Block" then return to "Idle".

    Similarly, if player "Dodge"s enemy's attack, enemy should be "Dazed", then return to "Idle".

    The nemy will sometimes attack directly out of the "block" or "Dazed" animation instead of waiting 4 seconds.

    Here are my events as I have them now:

    1.(Glob.Var.)AttackType=0

        Is anim "Idle" playing   :   Set AttackType to 1

        X Is anim "Idle" playing : Set AttackType to 0

    2.AttackType=1 : Wait 4 secs, Set anim to "Attack", Set AttackType to 0

    Trigger once :

    Thank you in advance!

  • The wait timer begins, and if enemy blocks at, say, 2 second mark, it will carry out the post-wait action 2 seconds later.

    I can't figure out how to "cancel" or "stop" the wait command. In other words, if something interrupts an event before its post-wait action occurs, how do I stop the post-wait action from occuring?

    Here is another attempt, which gives these results:

    <img src="http://www.flickr/photos/93326820@N05/8486076523/" border="0" />

  • Trying to post image again...

    <img src="http://www.flickr/photos/93326820@N05/8486076523/" border="0" />

    flickr.com/photos/93326820@N05/8486076523

  • Not 100% clear on this,as I cant see in your conditions what is triggering your idle animation...but will try to help,but I think you need to rework it a little..

    Also it would be better to use delta time rather than seconds as it would run the same speed on high and low spec machines

    play about with the delta time reduction to get the timing you want

    if attacktype is greater than 0...subtract 1.0*dt from attacktype

    if attacktype=0....do idle animation...

  • Thanks for the reply.

    My real questions is:

    I want the enemy to (basically) attack every 4 seconds ONLY if he is in his "Idle" animation.

    If his idle is interrupted, say by blocking the player's attack, I want his 4 second timer to reset.

    So every time his "Idle" animation starts, a 4 second countdown begins to his attack. I can't figure out how to implement this--how to have an action interrupt/cancel/restart/etc. the wait command from a previous event.

    p.s. The image I posted above contains only a small portion of the event sheet--enemy is set to "Idle" on finish of several other animations.

    As for dt, yes, I plan on implementing that in the future--trying to get the core gameplay working first. Lots to learn!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ah I see..set your first condition as before...but add a sub event should work

    .AttackType=1 : Wait 4 secs,

    sub event

    animation idle is playing >Set anim to "Attack", SetAttackType to 0

    Trigger once :

    but DT still better way to go when you find your feet..

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