• 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!

GML Depth in Isometric View

Petrik33

Member
Hello everybody. I have trouble updating depth of my object in isometric game: when the object takes the neccesary tile the depth works right but while moving the depth is always changing and the cube is dissapearing every step, "hiding" behind the house object. Here is the code of my step event (both of house and cube):

GML:
if(V!=0)
{
    currentTile[TILE.tX]=ScreenTo_tX(x,y);
    currentTile[TILE.tY]=ScreenTo_tY(x,y);
}

currentTile[TILE.tX]=clamp(currentTile[TILE.tX],0,MAP_W);
currentTile[TILE.tY]=clamp(currentTile[TILE.tY],0,MAP_H);

currentTile=global.theMap[# currentTile[TILE.tX],currentTile[TILE.tY]];

if(is_array(currentTile)) z=currentTile[TILE.Z];

depth=0-(currentTile[TILE.tX]+currentTile[TILE.tY]+z);
I have tryed moving depth changing code to the beginning but it doesn't help. So I hope somebody else who is more familiar with it all can help. PLease(
Maybe the problem is just that sprites don't fit the tile size, but still I am not sure wheter my code is right.
 

Attachments

rytan451

Member
Where's your origin in the tiles? It looks like one of your tile coordinates has the wrong sign when you're adding them up for the depth calculation.
 

Petrik33

Member
Where's your origin in the tiles? It looks like one of your tile coordinates has the wrong sign when you're adding them up for the depth calculation.
The origin of every sprite is top center adding in account that some sprites have bigger height, so the cube has the middle center origin and tiles have just top center origin.
 
Top