Windows [SOLVED] 2.5D collision order

Shavv

Member
fellow gamemakers,

I have been personally creating a 2.5D effect with sprites. I draw fake ramps and such to create imaginary collision in a 3D axis. That has been going well until the actual floor is a platform and he wants to collide with another one.

I use a Z variable just like in normal 3D games.

Here is an example of the (fake 3D) 2.5D drawn objects:
room view (hitboxes):

Sample of it working:

Now you got an overal idea of what im working with. I use similair codes to a normal top down view but just with a Z axis check on top of it. Now here is my issue:

This collision works fine on the ground:

This collision doesn't work IF the ID of the platform he is standing is newer or older then the one colliding. I haven't really found out if it would be the newer one or the older one, but i know for sure that the Instance order is messing up with this and that it sometimes work with newer or older objects. But I dont want to rely on instance order. Spoiler below is the issue. :

These are the codes I tried, but all had similiar or worse results:
Code:
instx=instance_place(x+(hspd),y,SOLID)
if (place_meeting(x+(hspd),y,SOLID) and z>instx.z)
{
 while(!place_meeting(x+sign(hspd),y,SOLID) and z<=instx.z)
 {
  x+=sign(hspd)
 }
 hspd=0
}


insty=instance_place(x,y+(vspd),SOLID)
if (place_meeting(x,y+(vspd),SOLID) and z>insty.z)
{
 while(!place_meeting(x,y+sign(vspd),SOLID) and z<=insty.z)
 {
  x+=sign(vspd)
 }
 vspd=0
}
Code:
if hspd>0
{
 if place_meeting(bbox_right+hspd,y,SOLID)
 {
  if z>other.z
  {
   while(!place_meeting(bbox_right+sign(hspd),y,SOLID))
   {
    if z<=other.z {x+=sign(hspd)}   
   }
  }
  hspd=0
 }
}

if hspd<0
{
 if place_meeting(bbox_left+hspd,y,SOLID)
 {
  if z>other.z
  {
   while(!place_meeting(bbox_left+sign(hspd),y,SOLID))
   {
    if z<=other.z {x+=sign(hspd)}   
   }
  }
  hspd=0
 }
}

if vspd>0
{
 if place_meeting(x,bbox_bottom+vspd,SOLID)
 {
  if z>other.z
  {
   while(!place_meeting(x,bbox_bottom+sign(vspd),SOLID))
   {
    if z<=other.z {y+=sign(vspd)}   
   }
  }
  vspd=0
 }
}

if vspd<0
{
 if place_meeting(x,bbox_top+vspd,SOLID)
 {
  if z>other.z
  {
   while(!place_meeting(x,bbox_top+sign(vspd),SOLID))
   {
    if z<=other.z {y+=sign(vspd)}   
   }
  }
  vspd=0
 }
}
Code:
if hspd>0
{
 instx=collision_rectangle(bbox_left,bbox_top,bbox_right+hspd,bbox_bottom,SOLID,0,0)
 if instx!=noone and z>instx.z
 {
  if !collision_rectangle(bbox_left,bbox_top,bbox_right+sign(hspd),bbox_bottom,SOLID,0,0) and z<=instx.z {x+=sign(hspd)}
  if hspd>0 {hspd=0}
 }
}

if hspd<0
{
 instxx=collision_rectangle(bbox_left+hspd,bbox_bottom,bbox_right,bbox_top,SOLID,0,0)
 if instxx!=noone and z>instxx.z
 {
  if !collision_rectangle(bbox_left+sign(hspd),bbox_bottom,bbox_right,bbox_top,SOLID,0,0) and z<=instxx.z {x+=sign(hspd)}
  if hspd<0 {hspd=0}
 }
}

if vspd>0
{
 insty=collision_rectangle(bbox_left,bbox_bottom+vspd,bbox_right,bbox_top,SOLID,0,0)
 if insty!=noone and z>insty.z
 {
  if !collision_rectangle(bbox_left,bbox_bottom+sign(vspd),bbox_right,bbox_top,SOLID,0,0) and z<=insty.z {y+=sign(vspd)}
  if vspd>0 {vspd=0}
 }
}

if vspd<0
{
 instyy=collision_rectangle(bbox_left,bbox_bottom,bbox_right,bbox_top+vspd,SOLID,0,0)
 if instyy!=noone and z>instyy.z
 {
  if !collision_rectangle(bbox_left,bbox_bottom,bbox_right,bbox_top+sign(vspd),SOLID,0,0) and z<=instyy.z {y+=sign(vspd)}
  if vspd<0 {vspd=0}
 }
}

EDIT:
Maybe i should mention the (max height of floor under me) code:
Code:
var inst;
inst=collision_rectangle(bbox_left,bbox_bottom,bbox_right,bbox_top,SOLID,0,0)
if inst!=noone
{
 if (z<inst.z)
 {
  zfloor=inst.z
 }
}

I would appriciate all the help. Thank you so much for taking the time to read,



Shavv.
 
Last edited:

Shavv

Member
Now I used:

Code:
var x_list = ds_list_create();
var x_num = instance_place_list(x+hspd, y, SOLID, x_list, false);
if x_num > 0
{
 for (var xi = 0; xi < x_num; ++xi;)
 {
  if z>x_list[| xi].z
  {
   while(!instance_place(x+sign(hspd),y,SOLID) and z<=x_list[| xi].z)
   {
    x+=sign(hspd)
   }
      
  
   hspd=0
  }
 }
}
ds_list_destroy(x_list);
and that also seems influenced by instance order, so also doesn't work.
 
Top