How do I make interact 3 same objects together

  • So let's say you have an item "box" which is a sprite.

    You have 3 "box" in your layout.

    Those "box" are overlapping each other, and I would like to make them interacting to each other this way :

    If a box is overlapping another box on the left, it goes 1 pixel on the right

    If a box is overlapping another box on the right, it goes 1 pixel on the left

    Currently, I have this :

    "box" is overlapping "box" at offset -1, 0 : Set X to Self.X+1

    "box" is overlapping "box" at offset 1, 0 : Set X to Self.X-1

    Which is working fine for 2 item, but not 3 or more.

    For each doesn't work either.

    Any advice ?

  • For this I like to use a family with box in it. I'd name the family "otherbox".

    for each box

    --- box overlaps otherbox at offset (-1,0) : box set x to self.x+1

    --- box overlaps otherbox at offset (1,0) : box set x to self.x-1

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ah ! working very well

    Thank you so much

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