Help with Block-Based Lighting System (Like Terraria) — How to Pass Light Value to Neighbor?

I’m currently working on a game similar to Terraria and I’m trying to implement a block-based lighting system
How my lighting idea works:
Each block has a variable called light that ranges from 1-15, where15 is the brightest
To simulate sunlight I spawn a row of blocks high above the world and cast*raycasts downwards.
When a ray hits the first block, I set its light = 15 (this is the topmost block that receives sunlight).

Then I want to propagate the light to adjacent blocks like this:

  • If a block has light > 1 it should check its4 direct neighbors(left, right, up, down).
  • For each neighbor:
    If neighbor.light < current.light - 1, set neighbor.light = current.light - 1
  • This way the light will “spread” outward and gradually decay.
    But my proplem ;All blocks are instances of one single object (only one object type in the object list).
    So I can’t directly reference BlockA or BlockB in GDevelop events.

I tried using Point is inside object to detect neighbors ,placing 4 points around the block but this didn’t work.
There’s no visual result or effect — it seems like the event doesn’t pick the correct neighbor block.
question:Is there any way to pass values like light from one block to a specific neighbor block (within a single object group)?
I’m trying to avoid creating multiple separate block objects just to reference neighbors.

I don’t have the time to discuss this right now but this project might give you an idea.

https://forum.gdevelop.io/t/collision-instance-and-animation-solved/57043/8?u=keith_1357

1 Like