How do I detect multiple overlapping objects?

0 favourites
  • 7 posts
From the Asset Store
Be quick and choose the right answer for the shown equation.
  • If 2 instances of object B are overlapping 1 instance of object A, how would I check a variable of both object B?

    To better explain:

    In my top-down project I have 'ground' sprites for the ground of each room (the ground of each room is separated). And between two different grounds there is a door. So the door is overlapping 2 grounds.

    Each ground has a 'room' variable that stores its IDD, to detect witch room the player is.

    I wanna know the 2 'room' values of both grounds that the door is overlapping. How would I?

  • Try "For each" as a sub-event:

    Door overlapping Ground
        For each Ground      ....
    [/code:2olscttg]
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Try "For each" as a sub-event:

    Door overlapping Ground
        For each Ground      ....
    [/code:1cznt9lu]
    

    Thanks dop2000;

    Well, this doesn't kill the riddle. I need to store ground.room to door.room1 (first ground) and ground.room to door.room2 (second ground). So I know what are the two grounds that the door is overlapping.

    I can do it setting room1 and room2 of each door manually, but the code would be very useful to use in other situations, and I didn't figure it out yet

  • This should work:

    Door overlapping Ground
        System-> Pick 0th Ground instance  :  Door Set room1=Ground.room
        System-> Pick 1th Ground instance  :  Door Set room2=Ground.room
    [/code:mbk8dw2f]
    
    You can also use Ground.pickedCount expression to check how many Ground instances are picked in this event.
  • This should work:

    > Door overlapping Ground
        System-> Pick 0th Ground instance  :  Door Set room1=Ground.room
        System-> Pick 1th Ground instance  :  Door Set room2=Ground.room
    [/code:12xi4gcj]
    
    You can also use Ground.pickedCount expression to check how many Ground instances are picked in this event.
    

    Thanks again dop2000

    Ooooh, pick nth instance! Shit I miss that sonofabitch ^^

    But it didn't work right yet, all doors are getting room1=0 and room2=1 as if I was picking the two first grounds of the layout and not the two ones the door overlaps. And yes, they are as a subevent of Door overlapping Ground.

    I tried picking both ground separately by lowest and highest 'room', same problem. It seems to ignore the 'Door is overlapping Flor' event and pick only two rooms at all.

    Tried making For Each Ground and Door events to pick then all but non works. :s

  • minigame This is strange. Could you share your capx?

  • dop2000 thanks man

    I will spent some more time with it today and if I still struggle I'll make a capx.

    Appreciated!

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