[Solved] How to make code work individually for each instance

Setup: I have a wall - TestWall - and a line of code that places the player - Bruk - in front of the wall if standing below and behind the wall if standing above. Player remains on same layer, 16, while the wall itself snaps to a layer below or above the player depending on player’s Y-position.

Issue: This only works for the first TestWall I put in the scene, and not the instances.

Hypothesis: The code is referring to the first TestWall’s y-position in relation to player and changing every TestWall’s z-order depending on the first TestWall’s location.

How do I make this code work independently for ever instance - i.e. check the y-position for each TestWall instance individually and change the z-order appropriately, instead of changing all the instances based on the original TestWall?

I feel like there’s a simple solution I’m missing.

Wrap your events inside a for each object special event.

Like @Gruk says.
Foreach TestWall
—> Your other events here.

Thanks guys! It worked.

1 Like