Creating a chain reaction using raycasts (SOLVED)


In my project, I have a complex keycard system which checks if you have the right key AND transponder for the key, depending on what region you’re in.

I want to make it so that when you open a keydoor, all adjacent keydoors will open shortly after in a chain reaction.

Think of how the bomb blocks from Kirby work. Kind of like that.

In the process, I’ve gotten stuck:

Even though I’m using raycasts to check adjacent tiles, the main problem is that the code thinks I’m referring to the keydoor I just opened, not the ones adjacent to it. Therefore, the code only runs for that keydoor when it’s opened, and doesn’t trigger any of the others to open.

When moving the “animation = ‘open’” condition from the event, it just automatically opens EVERY keydoor.

How can I tell the code to trigger the events for what’s being detected by the raycasts to create the chain reaction I’m looking for?


No, it’s only working with the one door that’s in the “Repeat for each instance…” block.

I would tackle this a bit differently. I would do the following:

  1. add 4 points to the KeyDoor object where an adjacent KeyDoor object could be placed.

  1. create a new small square sprite (say 1x1 or 2x2) and call it KeyDoorCheck.

  2. The following events:

You end up with:



Oh awesome, I didn’t even need raycasts after all then, thanks!