R
Rootmanko123
Guest
Hey there,
I managed to set up a 3D collision system using P3DC library, where I have one player and multiple table model objects (.gmmod) which are placed in the map as obj_table objects.
Now, the player object's collisions are set up simply like this:
collision_player = p3dc_begin_model();
p3dc_add_block(-8, -8, 0, 8, 8, 32);
p3dc_end_model();
Also, the table collisions are set up similarly:
collision_table = p3dc_begin_model();
p3dc_add_model("tablemodel.gmmod", x, y, 0);
p3dc_end_model();
Collision code is set up in the step event of the player like this:
if (p3dc_check(collision_player, x + hsp, y, 0, obj_table.collision_table, 0, 0, 0) == false) {
x += hsp;
}
if (p3dc_check(collision_player, x, y + vsp, 0, obj_table.collision_table, 0, 0, 0) == false) {
y += vsp;
}
Now, the player - table collisions work fine, however just with the first table instance that was placed in the room. When I place multiple instances of the table in the room, collisions work with only the first one that was placed, as I mentioned before.
I know there is a workaround, and that is to have a "map" object that loads all the model objects into one game maker object and then the player collides with the whole "map" object. That works fine, however, I want to be able to use the room editor to create my map and place different 3D model objects inside the editor. This way, I would have to model the whole map in a 3D model editor, which is not what I want.
Is there any way that I could make this collision code apply for every instance of the table object?
Any tips are appreciated, thank you for your time guys
Have a nice day.
I managed to set up a 3D collision system using P3DC library, where I have one player and multiple table model objects (.gmmod) which are placed in the map as obj_table objects.
Now, the player object's collisions are set up simply like this:
collision_player = p3dc_begin_model();
p3dc_add_block(-8, -8, 0, 8, 8, 32);
p3dc_end_model();
Also, the table collisions are set up similarly:
collision_table = p3dc_begin_model();
p3dc_add_model("tablemodel.gmmod", x, y, 0);
p3dc_end_model();
Collision code is set up in the step event of the player like this:
if (p3dc_check(collision_player, x + hsp, y, 0, obj_table.collision_table, 0, 0, 0) == false) {
x += hsp;
}
if (p3dc_check(collision_player, x, y + vsp, 0, obj_table.collision_table, 0, 0, 0) == false) {
y += vsp;
}
Now, the player - table collisions work fine, however just with the first table instance that was placed in the room. When I place multiple instances of the table in the room, collisions work with only the first one that was placed, as I mentioned before.
I know there is a workaround, and that is to have a "map" object that loads all the model objects into one game maker object and then the player collides with the whole "map" object. That works fine, however, I want to be able to use the room editor to create my map and place different 3D model objects inside the editor. This way, I would have to model the whole map in a 3D model editor, which is not what I want.
Is there any way that I could make this collision code apply for every instance of the table object?
Any tips are appreciated, thank you for your time guys
Have a nice day.