Stamos22
Member
Hello again,
I have a question concerning depth and an issue I can't solve.
I currently have tried two different ways of layering my objects in a top down pseudo 3d game.
The first, is to use depth = - y (some value). This has allowed me to make it possible for my character to go behind objects and create a sense of depth to the world. However, the problem here is that I use a spawner at map creation to throw down a random assortment of vegetation. When it does this, there are always a few trees that have weird depth problems - some of the ones at the top of the screen get drawn over ones that are lower on the screen.
The second method I have tried is Cosmonaut's depth code
This works great for the ranom tree spawning, but there is a problem with my player. I am using a separate object for his weapon (bow). The bow rotates on its origin like a turret and this is critical for the gameplay. The problem is that the bow draw behind the player when I use this code. I believe this is because the origin is above the player's origin? Though I may be wrong as I am a noob. If that's the case, I don't know what to do since the origin needs to be in the centre of the player in order for the bow to rotate properly.
Do any of you clever people have any ideas of how I might sort this out?
I have a question concerning depth and an issue I can't solve.
I currently have tried two different ways of layering my objects in a top down pseudo 3d game.
The first, is to use depth = - y (some value). This has allowed me to make it possible for my character to go behind objects and create a sense of depth to the world. However, the problem here is that I use a spawner at map creation to throw down a random assortment of vegetation. When it does this, there are always a few trees that have weird depth problems - some of the ones at the top of the screen get drawn over ones that are lower on the screen.
The second method I have tried is Cosmonaut's depth code
Code:
if ds_exists(ds_depth_grid, ds_type_grid) {
var depthGrid = ds_depth_grid;
var instNum = instance_number(o_par_depth);
ds_grid_resize(depthGrid, 2, instNum,);
var yy = 0;
with o_par_depth {
depthGrid[# 0, yy] = id;
depthGrid[# 1, yy] = y;
yy++;
}
ds_grid_sort(ds_depth_grid, 1, true);
yy = 0; repeat instNum {
var instID = ds_depth_grid[# 0, yy];
with instID {
event_perform(ev_draw, 0);
}
yy++
}
ds_grid_clear(ds_depth_grid, 0);
}
Do any of you clever people have any ideas of how I might sort this out?