GMS 2 Spine + bbox does not react properly?

Rob86

Member
Hi fellow-coders,

I am running into a strange issue (at least it is strange for me) and hope that someone of you might recognize this and help me out. So far I think it might be a bug in GMS2 but yeah I just want to be sure :)

I am using the following code to let sprites react to slopes:

Code:
#region Horizontal Collision
var calc_hsp = floor(hsp * global.slowtime);
// Check if we hit a platform or `solid` object
if(
    place_meeting(x + calc_hsp, y, obj_platform) ||
    place_meeting(x + calc_hsp, y, obj_object_solid)
)
{
    // Check if we need to move the Y position if dealing with a slope
    var yplus = 0;
    repeat(calc_hsp)
        if(place_meeting(x + calc_hsp, y-yplus, obj_platform) && yplus <= abs(calc_hsp*0.5))
            yplus++; else break;
   
    // Check if place still not free
    if(
        place_meeting(x + calc_hsp, y-yplus, obj_platform) ||
        place_meeting(x + calc_hsp, y-yplus, obj_object_solid)
    )
    {
        // Close the gap until we hit the platform or solid
        repeat(calc_hsp)
        {
            if(
                !place_meeting(x + sign(calc_hsp), y, obj_platform) &&
                !place_meeting(x + sign(calc_hsp), y, obj_object_solid)
            ) x += sign(calc_hsp); else break;
        }   
        hsp      = 0;
        calc_hsp = 0;
    }
    else
    {
        // We found a free place, lets set it
        y -= yplus;
    }
}
x += calc_hsp;
#endregion
And as you might notice in the picture below, the pixel sprite (that lovely green square in the right) is responding perfectly. But the Spine sprite (that bald guy with the red beard on the left) is ignoring it all. I am so confused!

Note: The white 1pixel border is my debug code that shows the bbox boundries.



I hope someone can tell me how I can get that cocky bald guy up that hill!

Thanks in advance :D
 

rIKmAN

Member
Is that bbox setup inside Spine using a Bounding Box attachment?
Is that white box drawn by you manually using bbox_* or are you using skeleton_collision_draw_set()?
Have you done any tests with the bbox shown to see if it returns collisions correctly with another object or the mouse pointer?
Is the sprite set to use precise collisions or not?

More info needed.
 

Rob86

Member
Is that bbox setup inside Spine using a Bounding Box attachment?
- It`s the mask in GMS2 itself

Is that white box drawn by you manually using bbox_* or are you using skeleton_collision_draw_set()?
- It is drawn from bbox_*
- When I use skeleton_collision_draw_set() I get "Draw failed due to invalid input layout"

Have you done any tests with the bbox shown to see if it returns collisions correctly with another object or the mouse pointer?
- Yes a position_meeting(mouse_x,mouse_y,obj_player) returns true on the right spots. I also used place_meeting(x,y,obj_player) on the slope instance but that does not respond.

Is the sprite set to use precise collisions or not?
- It`s set to Manual - Rectangle

Edit: I discussed with the animator. No Bounding Boxes are created in the Spine file. (Is this needed?)
 
Last edited:

rIKmAN

Member
Is that bbox setup inside Spine using a Bounding Box attachment?
- It`s the mask in GMS2 itself

Is that white box drawn by you manually using bbox_* or are you using skeleton_collision_draw_set()?
- It is drawn from bbox_*
- When I use skeleton_collision_draw_set() I get "Draw failed due to invalid input layout"

Have you done any tests with the bbox shown to see if it returns collisions correctly with another object or the mouse pointer?
- Yes a position_meeting(mouse_x,mouse_y,obj_player) returns true on the right spots. I also used place_meeting(x,y,obj_player) on the slope instance but that does not respond.

Is the sprite set to use precise collisions or not?
- It`s set to Manual - Rectangle

Edit: I discussed with the animator. No Bounding Boxes are created in the Spine file. (Is this needed?)
The Spine Blog Article from a long time ago explicitly states that unless a bounding box is made in Spine then no collision mask is generated by GM:
Once you have imported the animation, you can set the collision properties, but note that you are limited here to simply using precise collisions or bounding box collisions, and that the collision data for a skeletal animation is explicitly taken from the data provided. GameMaker: Studio does not generate any collision mask if the data is missing from imported file, meaning you simply won't get working collisions if the masks are not set correctly in Spine. Also, unlike bitmap sprites, the imported skeletal animation sprite cannot be modified in the editor in any way, meaning any changes that need to be made should be done in Spine and then re-imported into your game.
There has been no notice of anything changing regarding that since then so I would create a bounding box inside Spine as a test just in case that is what's happening here. It will take your animator 2mins to add one and export so it's worth trying before anything else.

That error message could be because you are trying to draw collision data that doesn't exist (ie. no bounding boxes inside Spine) although that sounds similar to a bug I reported a long time ago (and was fixed) when a Spine sprite was drawn using a shader: https://bugs.yoyogames.com/view.php?id=29157

Are you using shaders at all?
 

Rob86

Member
Thank you for your reply. I have asked the animator to add the Bounding Boxes. Yes I use a shader. One shader (so not per object). I`ll give an update when I tested the new Spine Sprite with the bounding box. Thanks again!
 

Rob86

Member
When I put a rectangle mask on the slope sprite it works. Other hitboxes work to. But with precise mask it does not work. Might this be an other cause?
 
Top