[solved]How do I make this condition?

0 favourites
  • 6 posts
  • 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.

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



  • Try Construct 3

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

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

  • thank you guys now I know how to do it with the timer behavior( which I didn't know it existed)!!

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

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

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