Enemy loop problem

Get help using Construct 2

Post » Sun Nov 04, 2012 7:21 am


Hi

I'm having a little trouble getting something to work and a bit confused as to why it won't work.

The basic logic I want to occur is when you hit the enemy first time it plays it's hit animation. If it get's hit a second time it plays it's death animation and the objects are destroyed.

What I originally tried was to include the 'on animation finished' command in the for each loop but this gave an error during testing (error at bottom). So I moved the 'on animation finished' commands outside of the for each loop but this now means it affects all the enemies and not just the unique UID enemy.

Screenshot of the enemy code below. Any ideas what I am doing wrong, what should I use instead of the 'on animation finished' command (I need to wait for the animation to finish otherwise the other condition becomes true and it dies straight away)

Thanks
Simon



B
8
S
2
G
1
Posts: 21
Reputation: 1,492

Post » Mon Nov 05, 2012 6:49 am

Why not just add a Family instance variable called "Health" to the enemy FAMILY...

Then when you hit the enemy instance set up an Action that subtracts half its Default Health on each hit..

then use the Variable Health = 0 function call to change your animation to the right one...these commands are called every tick anyway so you don't really have to worry about the system missing it..

The important thing to remember is to add a System "For Each" Enemy Family condition as well...this will make it work separately for every instance in the familymystazsea2012-11-05 06:52:57
When in doubt..or you are lost in a Zombie apocalypse or someone is giving you a hard time..Remember one thing..... Read the Construct 2 Manual..it will save your life.:)
B
30
S
11
G
8
Posts: 313
Reputation: 7,360

Post » Tue Nov 06, 2012 9:31 am

Thanks fro the reply Mystazsea.

I had a go with the family but still had the same issue. The basic problem is triggering a new event when an animation finishes playing. At the moment I can't put the 'on animation finished' command in any loops.

Are there other ways to do something after a certain animation has finished?

Thanks
Simon
B
8
S
2
G
1
Posts: 21
Reputation: 1,492

Post » Tue Nov 06, 2012 4:15 pm

Not sure off the top of the head why your specific animation isnt working, but there's an alternative way to trigger something when an animation finishes.

You can compare a value to which frame your animation is currently on.

so you could do "if death animation = frame 10 then"

B
50
S
21
G
8
Posts: 844
Reputation: 10,299

Post » Thu Nov 08, 2012 11:41 am

Ah, thanks Justifun. I will give that a go... that does sound like it will work.

Thanks again
Simon
B
8
S
2
G
1
Posts: 21
Reputation: 1,492


Return to How do I....?

Who is online

Users browsing this forum: Colludium and 29 guests