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: 186
Reputation: 2,360

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
24
S
10
G
3
Posts: 557
Reputation: 4,491

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: 186
Reputation: 2,360

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 :) )
Check out my awesome game Doptrix
B
17
S
9
G
29
Posts: 517
Reputation: 16,833

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.
Check out my awesome game Doptrix
B
17
S
9
G
29
Posts: 517
Reputation: 16,833


Return to How do I....?

Who is online

Users browsing this forum: jbr190 and 29 guests