Using only 4 events!
[u:1q7x4stt]What it does[/u:1q7x4stt]
If you run the cap it should be pretty self explainator what the engine does.
I got the idea from a game called 'Cactus Bruce and the Corporate Monkeys', when I noticed the bricks the monkeys stand on are able to suspend themselves in the air, but the lighter coloured bricks do not. While the object of the game was to destroy all the bricks, you could save yourself time by destroying the bricks which suspended themselves in the air, causing the lighter coloured bricks which were affected by gravity to fall into the ocean (and thus be destroyed)
Anyway I created a similar kind of falling engine where falling dirt can land on the magic golden capsules and will remain there until either the capsule is destroyed. Likewise, ground holds up other ground, and if theres no connection to a piece of ground that is suspended by a capsule, the ground falls.
[u:1q7x4stt]Theory to how such an engine works[/u:1q7x4stt]
To put it simply, a piece of ground will fall unless a piece of ground which its overlapping isn't falling, or it is overlapping a capsule.
To create this in the simpilist and easiest way, we use a variable 'canFall' which indicates to the objects if they might fall or not. It is assumed everything will fall until proven otherwise. First off we tell the capsules they cant fall. Next, its just a simple case of looping every object and checking to see if it is overlapping any other objects which cant fall.
[u:1q7x4stt]How it works [/u:1q7x4stt]
We place all the objects into 2 families: red and green, so that we can take advantage of how Construct handles individual Selected Object Lists for each family.
If we loop each Red, we can then test if Red overlaps Green. Even though Red and Green are infact refering to the same collection of objects, the objects selected are different, and so testing for an overlap between red and green will infact check for an overlap between the selected red and all the other objects on the layout.
After the overlap condition, Green now represents (if any) all the surrounding objects to the one in question (red). Finally we check to see if any of them wont fall. If the condition proves true, we can tell the object in question (red) that it also wont fall.
This leads to a problem though. An object wont know if it cant fall unless the object sounding it also knows at that particular time that it cant fall...and its possible that object will be further down the list and therefore wont know yet. As a quick fix to this, I made the event repeat itself for Red.Count. This is NOT the most efficient way, but it does solve the problem for now.
I think this once again demonstrates the power behind constructs event system, and perhaps provides a little more information about how families and stuff work.