Game Programming Help for Beginners!
Home Need Help? Start here!
Questions and Answers
Get Exclusive Stuff!
Email Newsletter

How do I make an object go in front or behind another object in Game Maker?


The key is something called depth.

Every object in Game Maker has a depth. When you create a new object, the default depth will be 0. If you put objects in a room, and all of the objects are at a depth of 0, there wont be much control over which object goes in front. In this case, the newest object you place in the room will be in front of the other objects.

To get custom depth for objects, change the depth number in object's properties. What number should you put in? It all depends on which objects you want in the front and which ones should be behind them. Check this out:

Let's say I have an object called objPlayer and set the depth to:

Then I have another object called objTree and set the depth to:

This means that in the game, when there is an objPlayer object and an objTree object, if they pass each other, the objPlayer will be in front of the objTree object. Why is that?

Because the lower the number, the more it will be in the FRONT. The higher the number, the more the object will be in the BACK! This is because object with the higher depth value are created first, and the objects with lower numbers are created last.

Also remember that the numbers don't have to stay in the 10's. If we take the above example and add one more object called objTree2 and set the depth to:

This means that now the 2nd tree object will be IN FRONT of all other objects with depth higher than itself, because it now has the lowest depth value.

Depth is very important when it comes to layering objects in a 2D game, and it becomes VERY important when doing 3D games because you will need objects to draw at different times so they can display correctly on the screen! Nice!

Page updated: March 23rd, 2015 @ 6:21 AM Eastern Time

Game Making Tutorials
Find tutorials about your favorite game creation software! Use the navigation below!

Game Maker: Studio
Help, References, and Tutorials
RPG Maker Fes
Help, References, and Tutorials
Help, References, and Tutorials

Download Books
Search Downloadable Books from

Home Questions and Answers Email Newsletter
Watch our YouTube channel Read our Twitter feed
Content and Design © 2012-2023 All Rights Reserved. | Privacy Policy | Terms of Service
All Copyrights and Trademarks of mentioned products are copyrights and trademarks of their respective owners.

As an Amazon Associate and Affiliate, Breakthrough Gaming LLC earns a commission on qualifying purchases from and through our website. Thank you for your purchases!

Our other websites: