Make enemies doing one action at a time

0 favourites
  • 10 posts
From the Asset Store
Time rewind like in "Braid". Choose objects that will be affected by time rewind
  • Hi guys,

    First of all I hope this is not a typically posted issue. I could not find what I am looking for.

    So here is my trouble : I'm trying to do a Beat Em Up style game with hand fights.

    My problem is that the enemy is doing several actions at the same time. For example he can

    attack even if he is supposed to play the "hurted" animation.

    I tried to solve it by using local variables like "If action = 0 Enemy can attack, and when action = 1

    he cannot because he is playing the hurted animation." and all with little timers but still it is doing

    everything at the same time and it looks gross.

    I think I must have missed something but I'm just running out of ideas... any suggestions ?

    Sorry if it is not very clear.

    Thanks

  • My suggestion would be to use booleans for actions.

    player.hurt = false

    player.attack = false

    In the loop determining what to play, where the player is supposed to attack, but is getting hit, which might render him incapable of hitting:

    event

    player.hurt = true

    action

    play animation being hurt

    set player.attack = false

    event

    player.attack = true

    player.hurt = false

    action

    play attack animation

    Remember to keep an eye on the order of things.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you for the quick answer !

    Looks like a good way that I should try. I will, and then repost feedback.

  • Hey Lennaert,

    It looks a bit better but still it is not clear. The enemy is able to attack me even if I

    keep punching him, like the attack event is finding a short delay to do it.

    Here is a screenshot of the event sheet piece :

    http://img11.hostingpics.net/thumbs/mini_480833Screen.png[/img][/img]

  • Add an event "for each enemy"

    add two sub events and put event 2 and 3 there.

  • Is that it ?

    I'm sorry man, still the same... It's confusing.

    I think it might be because of my dirty way to set "EnemyHurted" to false. As you can see, after

    being hit there is a delay of 1 sec and I set it to false again. It might be because of that isn't it ?

  • Seems like the wait actions are screwing up your code..

    I would suggest using the timer behaviour instead.

  • You could remove the waits, and have a extra event:

    Enemy on finished playing hurt animation, set hurt is false

    You set the enemy to attack directly after your hurt thing is over, does that need to be, or is the the attack triggered another way ? (I would assume some click or touch)

    You could add is attacking and invert it for the hurt boolean too.

    The idea of the boolean here is that it checks states before allowing something to happen.

    The for each loop should determine the state of the animations based on the booleans, and the booleans should be set by manual actions or calculations.

    Also, you proably should have some idle animation, which could be triggered in the loop with a:

    event

    not hurt

    not attacking

    actions

    play animation idle

  • I'll give it a try guyz, thank you so much.

  • I found something pretty ok with booleans and using animation's end as conditions like you suggested it.

    Thank you very much guys !

    So cool to get helped.

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