How do I create an infection

Get help using Construct 2

Post » Thu Oct 22, 2015 5:31 pm

Hello fellas constructors,

Luckily this is not a medicine question but code!

I have been working lately on a super hero skill which infects enemies when the hero collides them, leaving a goo that if it's touched (overlapping) by the hero for a second time it will stick him to it till the infection disappears after x seconds.

I have tried a few codes but always get problems specially when the hero is quite close to the enemy (I think it recognizes the overlapping as a collision) and the infection blinks on and off. Also, I'd like to know how do I achieve this having 12 enemies in the same level, which in most of the cases they won't be all infected at the same time.

Thanks in advance for any help the community can provide!
B
4
S
1
Posts: 34
Reputation: 416

Post » Thu Oct 22, 2015 5:47 pm

I would give the enemy an instance variable boolean "infected" and a timer behaviour

player on collision with enemy
--enemy is not infected
> enemy set infected to true
-- else player pin to enemy

enemy infected is true
system trigger once
> enemy start timer "infected" for 4 seconds

enemy on timer "infected"
> enemy set infected to false
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 » Fri Oct 23, 2015 1:14 pm

Wonderful Stain, it worked like a charm! I also made some tweaks and added another timer for the goo, so the hero can be trapped if it touches it as well.

I didn't know how powerful the timer behavior is. Thanks a lot, cheers!
B
4
S
1
Posts: 34
Reputation: 416


Return to How do I....?

Who is online

Users browsing this forum: Bootfit, brunopalermo, tarek2 and 7 guests