• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Isometric depth

D

deem93

Guest
Hello.
I'm having a problem with setting up depth for player character in an isometric game.
Some of my objects are not symmetrical so simply making the player disappear behind an object when they approach it from above does not work properly.
Any ideas how I could solve this issue?
Also can any of you point me to good tutorial on making isometric games in GameMaker?
Thanks!
 
L

Laurent57

Guest
Hi, i don't see the link with "symmetry" but do you have a screen capture of these objects?
 
K

Kobold

Guest
depth=depth-y;

Edit: That could go into the step event. And what it does is quite simple. You want anything towards the top to be deeper... so make use of the y variable for every object. Edit2: But make sure that every item has the same depth (same value stored in the depth variable at creation), and point of origin is the bottom of the objects sprite
 
E

elementbound

Guest
depth=depth-y;

Edit: That could go into the step event. And what it does is quite simple. You want anything towards the top to be deeper... so make use of the y variable for every object. Edit2: But make sure that every item has the same depth (same value stored in the depth variable at creation), and point of origin is the bottom of the objects sprite
I would advise writing depth=-y; instead, depth=depth-y will decrease it infinitely, eventually getting out of numeric bounds
 
K

Kobold

Guest
I would advise writing depth=-y; instead, depth=depth-y will decrease it infinitely, eventually getting out of numeric bounds
oh, yes that is right, haha... silly me.
Maybe create another variable in the creation event:
depth2=desired base depth
and then within the step event
depth=depth2-y;
 
L

Laurent57

Guest
Well, so why not just depth=-y ? :D

Sorry, i just read elementbound's post..
 
D

deem93

Guest
Hi again.
Thanks for all the replies.
depth =-y does work, but only for symmetrical objects. The object I have a problem with is, for example, this building.
The corners on the left and right side are not aligned, so there is no right place for the origin point.
That results in the player character often popping up in front or hiding behind the building too early.
The solution that I found is creating a "collision object", shaped like the roof and NW-NE walls of the building. When the player collides with this object, it hides them behind the building (and additionally it makes the building semi-transparent).
Code:
if instance_place (x, y, obj_player) {
   obj_building_01.depth = obj_player.depth -y;
   obj_building_01.image_alpha = 0.4
   }
else {
   obj_building_01.image_alpha = 1
   obj_building_01.depth = obj_player.depth +y;
   }
The problem that I have is that other objects that overlap with the building (eg. plants in front of it) tend to react to those depth changes as well.
I do not know how to get it to work properly.
Thanks in advance!
Building 1.png
 
P

ph101

Guest
You will need to break up your object in cells, store positions of each cell in a grid, and then render each cartesian position to isometric space. There will be no other reliable way to avoid what you describe. Also, if you don't do this you will have a lot of problems with pathfinding and colision.

GM 1.4 comes with a good isometric tutorial well worth trying - not sure if GM2 does but if you can find the 1.4 one will likely help. You should search the forum for posts on isometric rendering, come up a few times.
 

CMAllen

Member
Hi again.
Thanks for all the replies.
depth =-y does work, but only for symmetrical objects. The object I have a problem with is, for example, this building.
The corners on the left and right side are not aligned, so there is no right place for the origin point.
That results in the player character often popping up in front or hiding behind the building too early.
The solution that I found is creating a "collision object", shaped like the roof and NW-NE walls of the building. When the player collides with this object, it hides them behind the building (and additionally it makes the building semi-transparent).
Code:
if instance_place (x, y, obj_player) {
   obj_building_01.depth = obj_player.depth -y;
   obj_building_01.image_alpha = 0.4
   }
else {
   obj_building_01.image_alpha = 1
   obj_building_01.depth = obj_player.depth +y;
   }
The problem that I have is that other objects that overlap with the building (eg. plants in front of it) tend to react to those depth changes as well.
I do not know how to get it to work properly.
Thanks in advance!
View attachment 14914
You're going to have to split that into multiple pieces. This is a limitation of simulating 3d space with 2d planar images.
 

JackTurbo

Member
As other have mentioned you'll likely need to split out big terrain pieces into small bits for depth sorting.

Also depth = -y isnt sufficient either you need
depth = -(y + x);
 
Top