How do I detect an overlap of several instances of the same object ?

0 favourites
  • 8 posts
From the Asset Store
Several elements of the game interface hidden objects
  • Hello !

    I have several green squares in my scene (same object but several instances of it) and I have a circle that I can move.

    I would like to activate an action when the circle is overlapping more than one square but I don't find the correct event.

    Could someone help me ? Thanks a lot !

  • You could check if the circle is overlapping a square. Then set a variable to that square's UID. Then check again if the circle is overlapping a square but only ones that dont have the UID of the first one.

  • I think you can use expression ".Count" for the green squares, something like red circle is overlapping green and green.Count > 1

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could probably run a for each square loop

    set global variable squarecount, then for each square if overlapping circle add 1 to that variable, so you should get exactly how many are overlapping.

    Don't forget to reset thev ariable to 0 before the loop, otherwise it will just keep adding up

  • I'm not sure I understand BadMario. I put the .c3p file here if you want to take a look.

    Here is my event sheet but it makes the global variable increase, it doesn't count the number of overlapping squares. :/

  • I'm surprised that there is no option in the "overlap" event to choose the number of instance to overlap in order to activate the action.

  • Might be simpler to just check the "PickedCount" expression under the overlapping condition.

    + Circle: Is overlapping Square

    + System: Square.PickedCount >= 2

    -> (Do something)

  • I absolutely didn't know about this expression, thanks a lot Magistross !

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