# Walking over walls - Game maker studio

I am having an issue with the walls in my game. I have set them as objects and used the script:

depth = -y;

inside their create event.

However, when I walk my character in front of them, the correct depth is only kept until the character kindof goes half in front of the wall.

Like this:

These are the collision shapes

And this shows how I inherit from one door parent and add the depth = -y; script to the create event of the wall child.

My character also has depth = -y; but on its step event.

1. You should use depth = -y; in Step End, not Step.
2. Where is sprite's origin? It must be at bottom of the sprite (the lowest point of the sprite)(this applies to each object/sprite where used depth = -y;)
• @johan855 I meant that you had two different errors, not one of them. Because when you use Step instead Step End you may have a small lag between y and depth (for example, when you use speed, hspeed, vspeed and any other different from x += value). – Dmi7ry Jul 6 '17 at 6:21
• Other than using the depth = -y snippet, you should also make sure sprite origins are properly set: since collision works upon collision masks, try to set the origin at the geometrical center of each mask, so that the player will never have a greater y value (thus a smaller depth value) than the wall object. – liggiorgio Jul 6 '17 at 18:41