C
cambalinho
Guest
i'm doing a 3D colision function:
and works fine. but now i'm update it for all solid objects\instances:
i tried get the instance size\position and the values was correct. but seems not be compared on 'if'. can anyoned explain to me what i'm doing wrong?
Code:
///Collision3D(PosX1, PosY1, PosZ1, W1, H1, P1, PosX2, PosY2, PosZ2, W2, H2, P2);
PosX1=argument0;
PosY1=argument1;
PosZ1=argument2;
W1=argument3;
H1=argument4;
P1=argument5;
PosX2=argument6;
PosY2=argument7;
PosZ2=argument8;
W2=argument9;
H2=argument10;
P2=argument11;
if ((PosX1 < (PosX2 + W2)) && (PosX2 < (PosX1 + W1)))
{
if ((PosY1 < (PosY2 + H2)) && (PosY2 < (PosY1 + H1)))
{
if ( (PosZ1<(PosZ2+P2)) && (PosZ2<(PosZ1+P1)))
{
return true;
}
}
}
return false;
Code:
///Collision3DAllObjects(PosX1, PosY1, PosZ1, W1, H1, P1);
PosX1=argument0;
PosY1=argument1;
PosZ1=argument2;
W1=argument3;
H1=argument4;
P1=argument5;
for (i=0;i<(instance_count-1);i++)
{
if instance_id[i].solid==true
{
PosX2=instance_id[i].x;
PosY2=instance_id[i].y;
PosZ2=instance_id[i].z;
W2=instance_id[i].w;
H2=instance_id[i].h;
P2=instance_id[i].p;
if ((PosX1 < (PosX2 + W2)) && (PosX2 < (PosX1 + W1)))
{
if ((PosY1 < (PosY2 + H2)) && (PosY2 < (PosY1 + H1)))
{
if ( (PosZ1<(PosZ2+P2)) && (PosZ2<(PosZ1+P1)))
{
return true;
}
}
}
}
}
return false;