Check for no overlapping between family instances

  • Hi folks,

    I'm trying to do something like a level editor. I want to prevent solid objects to be stacked on top of each other. I have a condition that checks if there is an overlap - in that case, the solid objects can't be placed in the level.

    But it seems I'm lacking the skill to write a condition that checks if the overlapping has stopped. I tried several versions with boolean variables and without. The stopping condition seems to fire every tick. I created a simplified version attached below (there are several hundred placeable objects in the original project, so this should really work with families). Can anyone point out to me how the condition can be fixed?

    Project: https://gofile.io/?c=9bWURJ

    Conditions:

    Editor:

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Took me a while to understand your code, and the fact that all objects are named "Sprite" didn't help :)

    Here is the fixed version, I used drag&drop behavior and a clone family:

    dropbox.com/s/uunoysubsawqzz6/Test_leveleditor.capx

    When you drop the object and it's overlapping another object, instead of destroying it you can return it to its previous location. Use a pair of instance variables to store previous x and y.

  • Thanks man, the clone family is a nice workaround! I'm trying to create more of a stamp system than a drag&drop one (my capex didn't indicate that, sorry) - but it should work with the clone family. Thanks again!

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