[solved]How do I make this condition?

Get help using Construct 2

Post » Thu Jul 23, 2015 11:02 am

hey guys,

I want to make a certain condition to my event but don't know how, the condition is::

sprite 1 on collision with sprite 2 for 2 seconds.

the problem is with the two seconds (meaning : don't activate the event unless the collision has last 2 seconds )??
please help.
Last edited by Moun glow on Thu Jul 23, 2015 11:31 am, edited 1 time in total.
B
11
S
2
G
1
Posts: 84
Reputation: 852

Post » Thu Jul 23, 2015 11:11 am

One way I would try would be so that on collision, a certain variable (for the sake of this example call it 'switch') is set to 1, so:

Sprite 1 on collision with sprite 2 -> 'Switch' = 1

Then have a second condition that is Sprite 1 is NOT in collision with sprite 2, set 'switch' back to 0.

However, make a third condition where if sprite 1 is in collision with sprite 2, AND 'Switch' = 1, wait 2 seconds before setting 'switch' to 3, then use "If switch = 3" for the condition for your event.

I'm not sure if this will work fully, but it's worth an attempt.

Hope this helps some!

Regards,
Gideon.
B
10
S
1
Posts: 72
Reputation: 1,015

Post » Thu Jul 23, 2015 11:16 am

Easiest way would be using the timer behaviour:

Sprite1 on collision with sprite2
> Start timer "overlapping" for 2 seconds

Sprite1 is not overlapping sprite2
> stop timer "overlapping

On timer "overlapping
> add wanted action
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 Jul 23, 2015 11:30 am

thank you guys now I know how to do it with the timer behavior( which I didn't know it existed)!!
B
11
S
2
G
1
Posts: 84
Reputation: 852

Post » Thu Jul 23, 2015 11:37 am

@GideonG the problem with that is the wait event will still fire after the two seconds, even if the collision ended before that. Once the engine gets to that wait event, if the condition becomes false before the wait is over it will finish the events after the wait resulting in switch being set to 3 no matter what, just 2 seconds after the intial collision.
B
46
S
14
G
7
Posts: 603
Reputation: 8,106

Post » Thu Jul 23, 2015 12:16 pm

@EncryptedCow I did wonder about that, yeah. It's an issue I've never come across, but yeah, now you say that it makes perfect sense. :D
B
10
S
1
Posts: 72
Reputation: 1,015


Return to How do I....?

Who is online

Users browsing this forum: dop2000, namaewayukidesu, Yahoo [Bot] and 7 guests