Make enemies doing one action at a time

Get help using Construct 2

Post » Thu May 14, 2015 7:27 am

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
B
20
S
3
Posts: 36
Reputation: 972

Post » Thu May 14, 2015 7:32 am

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.
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Thu May 14, 2015 7:41 am

Thank you for the quick answer !

Looks like a good way that I should try. I will, and then repost feedback.
B
20
S
3
Posts: 36
Reputation: 972

Post » Thu May 14, 2015 8:07 am

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 :

[img][IMG]http://img11.hostingpics.net/thumbs/mini_480833Screen.png[/img][/img]
B
20
S
3
Posts: 36
Reputation: 972

Post » Thu May 14, 2015 8:24 am

Add an event "for each enemy"

add two sub events and put event 2 and 3 there.
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Thu May 14, 2015 8:48 am

Is that it ?

Image

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 ?
B
20
S
3
Posts: 36
Reputation: 972

Post » Thu May 14, 2015 10:02 am

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

I would suggest using the timer behaviour instead.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu May 14, 2015 10:06 am

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
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Thu May 14, 2015 11:13 am

I'll give it a try guyz, thank you so much.
B
20
S
3
Posts: 36
Reputation: 972

Post » Thu May 14, 2015 12:40 pm

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.
B
20
S
3
Posts: 36
Reputation: 972


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, jaytrott86 and 7 guests