[Solved] How to detect an object below him?

0 favourites
  • 3 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • What should my capx do?

    Every Blok check if below him is a Blok. When there are none, the Blok will move down to his spot.

    The challenge is how the Bloks knows if there is no Bloks below him.

    What I have done

    I have been using an array for this problem.

    A set of Bloks has an RowID and ColumnID. These are used to insert value in the array.

    If a Blok exist, he will set in the array at x=Blok.ColumnID,y=Blok.RowID as value=1

    When a Blok got destroyed, the value in the array at x=Blok.ColumnID,y=Blok.RowID becomes value=0

    Each Blok checks in the array at x=Blok.ColumnID,y=Blok.RowID+1 (the row below the current Blok), if this value is zero. The Blok will move down performing the following actions.

    In the array at x=Blok.ColumnID,y=Blok.RowID value become zero

    The row below will receive a value=1

    The old RowID of the block will change to RowID+1

    There after an event will snap these Bloks to the Nodes with the same ColumnID and RowID.


    When you destroy many blocks in a short time. A bug will appear. It prevents Bloks from moving down or getting spawned. Value 1 are assigned to the array while there are no Bloks in that position.

    Can someone explain me what is causing this problem? When possible, how can I solve it?

    This can be solved by resetting the entire array to zero and putting in value=1 back in the array. This works, but it require many unnecessary "for each loops".

    If there are others ways to do this, please let me know

    I'm really having hard time figuring out what is causing this bug

    Thanks in advance for helping

    Here is the capx


    Edit: Changed the title so [Solved] can fit in

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You are missing a "For each Blok" under your line 3 condition. If more than a block is destroyed in a tick, your array will start to desync with the actual grid.

  • You are amazing, that did the trick

    Thank you very much!

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