0
\$\begingroup\$

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:

enter image description here

enter image description here

These are the collision shapes

enter image description here

enter image description here

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

enter image description here

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

\$\endgroup\$
1
\$\begingroup\$
  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;)

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ I added depth = -y; into the end step event, however its still having problems, I think the error must come from the origin of the character being almost in the middle and not in the bottom as you say, will check and come back if it works \$\endgroup\$ – johan855 Jul 5 '17 at 19:26
  • \$\begingroup\$ worked well by re setting the origin of my characters sprites to the lowest pixel. Thanks! \$\endgroup\$ – johan855 Jul 5 '17 at 19:32
  • 1
    \$\begingroup\$ @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). \$\endgroup\$ – Dmi7ry Jul 6 '17 at 6:21
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – liggiorgio Jul 6 '17 at 18:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.