Moving behind objects (SOLVED)

I’m a newcomer to Defold, been playing around with creating a level and trying to pull off a 2.5d view

I’ve set two characters with the same Z position, what’s the best way to handle if the one character going behind another? Should I be changing the Z position of one of them based on the X position other, or is there a more better way of handling it?

If your camera is setup with the Z axis being the depth (normal case) then all you need to do is to set the Z value accordingly.
In Defold you don’t have to emulate 3D look for 2.5D, you can actually use 3D, tilt the camera angle so that it matches the look you want and it should work.

1 Like

Take a look at awesome 2.5D prototype by @dragosha Slasher-prototype [open source]

4 Likes

Thanks, good code to look through,
I’ve pulled off a similar after looking through the prototype, using the update function I’m going through the game objects and adjusting their Z value based on the Y axis being greater or less than my character’s Y axis, hence it’d shift my character in-front or behind the objects depending.

Cheers!

1 Like