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

Legacy GM Need help with collisions in 3D

Status
Not open for further replies.
Hello, I've been working on a 3D game in game maker for a while. I just needed help with my collisions. So everyone knows the function d3d_draw_block now, I made only 1 block into my game with 1 texture. When I tried to add more blocks I could put the texture and stuff like that. But I couldn't make the collisions work. I tried to duplicate the collisions code and just change them for the specific block, but that didn't worked. Anybody can help me? Thanks.
Btw here is the code for the collisions:
if (!place_meeting_ext(x + x_vel, y, z, par_solid)) {
x += x_vel
} else {
// start taking our "baby steps" one pixel at a time until we eventually collide.
while (!place_meeting_ext(x + sign(x_vel), y, z, par_solid)) {
x += sign(x_vel);
}
// we have broken out of the while loop so we must be at the solid. now stop.
x_vel = 0;
}
if (!place_meeting_ext(x, y + y_vel, z, par_solid)) {
y += y_vel
} else {
// start taking our "baby steps" one pixel at a time until we eventually collide.
while (!place_meeting_ext(x, y + sign(y_vel), z, par_solid)) {
y += sign(y_vel);
}
// we have broken out of the while loop so we must be at the solid. now stop.
y_vel = 0;
}

if (!place_meeting_ext(x, y, z + z_vel, par_solid)) {
z += z_vel
} else {
// start taking our "baby steps" one pixel at a time until we eventually collide.
while (!place_meeting_ext(x, y, z + sign(z_vel), par_solid)) {
z += sign(z_vel);
}
// we have broken out of the while loop so we must be at the solid. now stop.
z_vel = 0;
}

Keep in mind this worked only for one block, when I tried to copy it and change it for another block, it didn't worked.


Anyways here is the place_meeting_ext script:

///place_meeting_ext(x, y, z, obj)
// This collision script only works if the sprite of the object
// calling it is centred.

xx = argument0;
yy = argument1;
zz = argument2;
obj = argument3;

with (obj) {
var hw = other.sprite_width * 0.5;
var hl = other.sprite_height * 0.5;
var h = other.height;
if (other.xx > x - hw + 1 &&
other.xx < x + sprite_width + hw - 1 &&
other.yy > y - hl + 1 &&
other.yy < y + sprite_height + hl - 1 &&
other.zz > z - h + 1 &&
other.zz < z + height - 1) {
return true;
}
}
return false;
any help? thanks
 
Status
Not open for further replies.
Top