Below is the script i made to check for collisions before moving a crate.
// scr_d3d_model_collision();
// argument0: calling id
// argument1: calling collision id
// argument2: calling x pos
// argument3: calling y pos
// argument4: calling z pos
// argument5: object to check
if (argument5 != -1)
{
with(argument5)
{
if (argument0 != id)
{
if (col_id != -1)
{
// static collision
if (col_type = 0)
{
if (p3dc_check_still(argument1,argument2,argument3,argument4,col_id) = true)
{
argument0.obj_id = id;
return true;
exit;
}
}
// dynamic collision
if (col_type = 1)
{
if (p3dc_check(argument1,argument2,argument3,argument4,col_id
,x,y,z) = true)
{
argument0.obj_id = id;
return true;
exit;
}
}
}
}
}
}
return false;// crate step event
// movement
if (scr_d3d_model_collision(id,col_id,x+x_speed,y,z,obj_col_parent) = false)
{
x += x_speed;
} else x_speed = 0;
if (scr_d3d_model_collision(id,col_id,x,y+y_speed,z,obj_col_parent) = false)
{
y += y_speed;
} else y_speed = 0;
// friction
spd = point_distance(0,0,x_speed,y_speed);
spd_dir = point_direction(0,0,x_speed,y_speed);
if (spd > 0)
{
if ((spd-0.1) > 0) spd -= 0.1; else spd = 0;
x_speed = lengthdir_x(spd,spd_dir);
y_speed = lengthdir_y(spd,spd_dir);
}Thanks, Jepie0









