How do I test if object overlaps another for X seconds

0 favourites
  • 6 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • 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.

  • 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)

  • 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.

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)