When Enemy overlaping X for 3 seconds then..

Get help using Construct 2

Post » Tue Oct 03, 2017 5:29 pm

Hey
Is it possible to make action when enemy overlaping object X for 3 seconds then destroy enemy?
thanks!
B
10
S
4
G
2
Posts: 198
Reputation: 2,384

Post » Tue Oct 03, 2017 5:42 pm

You can create an instance variable on the enemy sprite called "time".

In events set that:
Enemy is overlapping X object
+
every 1.0 second

Then >> Add 1 to "time" instance variable of the enemy

Finally:
If Enemy "Time" instance Variable is 3 = Destroy enemy
B
27
S
10
G
3
Posts: 596
Reputation: 4,644

Post » Tue Oct 03, 2017 5:55 pm

@matriax
matriax wrote:You can create an instance variable on the enemy sprite called "time".


thanks man
heh this is 50 th variable in my game, so don't know is it Healthy? ;-)
B
10
S
4
G
2
Posts: 198
Reputation: 2,384

Post » Wed Oct 04, 2017 3:57 am

heh this is 50 th variable in my game, so don't know is it Healthy?

The limit for variables is 55, so you are fine!


(I'm joking of course :) )
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :)
B
17
S
9
G
69
Posts: 1,048
Reputation: 37,659

Post » Wed Oct 04, 2017 7:02 am

Don't forget to reset the time variable when it's no longer overlapping! Unless you want the seconds to stack.
B
27
S
10
G
2
Posts: 237
Reputation: 3,330

Post » Wed Oct 04, 2017 7:35 am

Another easy way to do this is to start a timer for 3 seconds on Enemy instance when sprites overlap.
On timer event - destroy the enemy.
If sprites no longer overlapping - stop the timer.
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :)
B
17
S
9
G
69
Posts: 1,048
Reputation: 37,659


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests