Hey, i was able to make it work with 2 skeletons, but after some testing realized it's gonna become a real pain eventually. So i'm trying my best again to make it work with just 1 skeleton and 2 collision masks (1 for collision with solids, 1 for weapon).
However, even after reading dozens of posts regarding related topics, i'm unable to find the proper way to set this up, and i realized i was messing up in my previous attempts.
How would you create a simple collision system with solid objects when the character has 2 collision boxes so that it only uses the main one and not the weapon? is there a correct way to check collisions using a particular spine bounding box? My collisions are done using the most popular system amongs tutorials, using place_meeting, so for example, vertical collision:
Code:
if (!place_meeting(x, y+1, oSolid)){
vspeed_ += gravity_;
} else {
if (keyboard_check_pressed(vk_up)) {
vspeed_ = jump_height_;
}
}
if (place_meeting(x, y-1, oSolid)){
while (!place_meeting(x,y+sign(vspeed_), oSolid)) {
y += sign(vspeed_);
}
vspeed_ = 0;
}
y += vspeed_;
So trying to use the spine bbox, i did this in the character's create event:
Code:
main_map = ds_map_create();
On animation update:
Code:
ds_map_clear(main_map); // tried with and without this in both orders, same result
skeleton_bone_state_get("main", main_map);
That would let me get the worldX and worldY (which are relative to the animation) of the main bone, which has the bounding box, so in step im doing the following to get the x and y position for the bbox:
Code:
ypos = y + real(main_map[? "worldY"]);
xpos = x + real(main_map[? "worldX"]);
Afterwards i modified the vertical collision like this:
Code:
if (!place_meeting(xpos, ypos+1, oSolid)){
vspeed_ += gravity_;
} else {
if (keyboard_check_pressed(vk_up)) {
vspeed_ = jump_height_;
}
}
if (place_meeting(xpos, ypos-1, oSolid)){
//while (!place_meeting(xpos,ypos+sign(vspeed_), oSolid)) {
// y += sign(vspeed_);
//}
vspeed_ = 0;
}
y += vspeed_;
This actually worked on windows after commenting out the while loop (since it would freeze the game because the ypos wasn't actually updating until the next animation end), but not on HTML5. Everything just became super buggy and my character gets stuck everywhere.
I'm pretty sure my solution is really bad though, that's why i'm asking for some pointers on how to approach this correctly, but just wanted to show that i'm not begging for and answer about something i haven't even tried to solve myself haha.
But yeah, what i need is basically 1 skeleton with 2 bounding boxes, and using the main one for collision with solids and the other one when i require it to collide with enemies.
(and regarding the original topic question, i just tested it with a fresh project and it definitely seems to be a bug in HTML5 only, i'm gonna report it before going to sleep tonight)