How do I test if object overlaps another for X seconds

Get help using Construct 2

Post » Mon Sep 26, 2016 2:46 am

I'm trying to get a lever animation to play only if that lever overlaps the player for 1.5 secs.

I tried compare time, but ofcourse that didn't work. Would i need to use dt* for this? Or what events do i need to get something like:

Lever > overlapping Player for 1.5 secs - Lever > Play animation from beginning


Any help is greatly appreciated.
B
38
S
18
G
19
Posts: 664
Reputation: 14,107

Post » Mon Sep 26, 2016 4:32 am

Hey there!

I would try something like this:

create a numeric variable for the lever.

If player is overlapping Lever:
-every 0.5 seconds add 0.5 to variable.

If player is not overlapping lever:
-set variable to 0

If variable is greater or equal to 1.5
Set animation to (your animation name)
B
64
S
38
G
24
Posts: 352
Reputation: 17,981

Post » Mon Sep 26, 2016 2:14 pm

Thanks for the reply. Unfortunately its not working. I've tried local, constant variables, moving/adding subevents, actions, events....still not working.

Basically its just a switch. I have the collision small and low on the lever, so the player can jump over it and not activate it.

On the 1st collision the lever is on > a MINE CART rolls out from a tunnel.

On 2nd collision the lever is off > MINE cart rolls back into the tunnel.

Any ideas or any more help would be awesome.
B
38
S
18
G
19
Posts: 664
Reputation: 14,107

Post » Mon Sep 26, 2016 2:53 pm

I just want to make sure I'm understanding you. Everything works right now with collisions being used as the trigger (?); you just want to wait 1.5 seconds before the cart rolls out. (so less an animation trigger and more a behavior that's activated)

EDIT: So assuming the first post is what we're looking for, I made a quick example using the sample platformer capx. https://www.dropbox.com/s/rqa4jy2xdkauj ... .capx?dl=0 Otherwise I'll have to whip something up later today.
Last edited by ultrafop on Mon Sep 26, 2016 3:23 pm, edited 1 time in total.
B
64
S
38
G
24
Posts: 352
Reputation: 17,981

Post » Mon Sep 26, 2016 3:13 pm

No.

The initial ON lever frame points at 10 o'clock. On first collision the ON animation plays. The lever stops at 2 o'clock. The cart rolls out.

2 o'clock is the initial OFF position. If the player collides with the lever again, the OFF animation plays, stopping at 10 o'clock. The cart rolls back into the tunnel.

At first, the 1.5 seconds was only so if the player runs past the lever it will not toggle, but if the player overlaps the lever for 1.5 secs, it will toggle.

I've sinced made the collision box small enough so the player can jump over the lever and NOT activate it.
B
38
S
18
G
19
Posts: 664
Reputation: 14,107

Post » Mon Sep 26, 2016 4:34 pm

ImageImageImage
B
71
S
22
G
240
Posts: 3,734
Reputation: 133,994


Return to How do I....?

Who is online

Users browsing this forum: Artcadev, brunopalermo and 30 guests