• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

HTML5 Spine bone state issue with HTML5

M

Maigal

Guest
Hello, i'm using GM 2 latest version, and have tried the following with spine v 3.4.02 and various 3.5+ verions. so it doesn't seem to be a spine version issue.

What i need to do is basically use the built in function skeleton_bone_state_get to get the current state of a bone. After storing that data in a map, i draw it into the screen, but the values are mismatching in HTML5 and in Windows after running my project

In windows i get the correct ones based on the documentation, but when i export to HTML5 i only get:
x, y, angle, xscale, yscale, worldX, worldY, parent. So i'm pretty much missing all the world variables except for worldX and worldY.

Is this somehow the intended behavior or a straight up bug? Is it fixable?
 
M

Maigal

Guest
Any ideas about this? still unable to find anything :(
How would i calculate the worldAngle otherwise without that property exposed to me?
 

rIKmAN

Member
What do you mean by “missing”?

The values are 0 or they don’t even exist in the returned map?
 
M

Maigal

Guest
What do you mean by “missing”?

The values are 0 or they don’t even exist in the returned map?
They don't exist in the returned map.
If i export to windows everything works as intended, but the returned map only contains x, y, angle, xscale, yscale, worldX, worldY, parent only when exporting to HTML5.

I'm really lost about this and i can't really find anything even kinda related to this anywhere, sounds like just a HTML5 only bug to me
 

rIKmAN

Member
I can’t test this as I haven’t returned home from my Xmas holidays yet.
How are you verifying the values aren’t returned in the map?
 
M

Maigal

Guest
I'm using a draw event to draw either the whole ds_map where i'm storing the bone data or directly trying to access the property i need by using map[?"worldAngle"] (might be worldAngleX/worldAngleY instead of worldAngle, cant' remember and cannot check atm because i'm at work now). And well i also tried assigning those values to a variable and reading their value but it's always undefined as expected.

I think spine + GM HTML5 is super buggy honestly, because i've noticed some inconsistencies between windows and HTML5, mostly regarding collisions (the only reason i'm trying to get this to work is because html5 collisions are buggy as well, trying to find a workaround without using spine bboxes :/ )
 

rIKmAN

Member
When you get a chance use the debugger to check the actual contents of the returned map, this will confirm whether the actual values are not in the map at all or are in the map but not being assigned values correctly.

I suspect the second one but as I say I can’t help test it at the moment as I don’t return home for a few days yet.

Why are you trying to avoid using Spine bounding boxes?
What is it you are actually trying to do?
 
Last edited:
M

Maigal

Guest
Alright, i'll give that a try once i get back from work, thanks for the suggestion.

And regarding the spine bboxes, after trying pretty much everything i found i couldn't find a decent way to use my main skeleton bounding box to only collide with the solid objects, and my weapon's bounding box to collide only with the enemies, it became a big mess really quickly, and most stuff actually worked properly when exported to windows, so i sorta gave up and was hoping for it to be fixed in the big GM 2.2.2 spine update
 

rIKmAN

Member
The coming Spine update will,add some features and bring the current runtime support up to date (at last!), but I highly doubt it will bring any changes to the way it does collisions using Spine bounding boxes.

I wrote an extension which also allows the colouring / detection of individual slots at a given x/y which could be used to do this, although both of these functions seem to be finally being added natively in that 2.2.2 update whenever it may arrive.

Another approach might be to have the weapon and character as separate skeletons and positioning the weapon on the position of a “weapon bone” which you create on the character skeleton.

This would allow you to animate the character and have the weapon follow automatically by just grabbing the position of that bone from the map and using it as the x/y of the weapon - which would then also have its own set of animations (sword slash etc) and its own scale / rotation etc.

You can load in multiple skeletons to a single Spine project to and export them separately easily enough, which would allow you to tweak the animations and bone position to look correct before exporting separate json files to load into GMS. Just a thought, anyway.
 
M

Maigal

Guest
My debugger doesn't seem to recognize or at least for some reason won't read my player instance, but after looping through the ds_map in a different way i managed to draw some extra values, i assume drawing a json encoded ds_map ignores the undefined values.
So right now i've got this in HTML5:
https://i.imgur.com/pdk5Twn.png

And this in Windows:
https://i.imgur.com/s43WYP2.png

So yeah seems like some kind of bug which i'll try to report correctly.
In the meantime, your multiple skeletons idea seems really good and i'll go ahead and try that.

And yup, i know about your extension, i even bought before i found the upcoming 2.2.2 changes, but i don't regret it because thanks to a lot of your posts i learned a lot and i'll be using the blending functions until 2.2.2 arrives haha
 

rIKmAN

Member
The second image doesn’t seem to be loading for me.

For reference, set a breakpoint just before the ds_map gets filled with the data, then open up the instance in the debugger and make sure to set the map variable to be shown as a ds_map and then step through the code.

You should see the map fill with data from the skeleton and can see what it actually contains.

Oh nice - glad the extension helped you out and thanks for the purchase.

If you have any issues with the 2 skeleton method hit me up and I’ll be happy to help, but it’s as simple as reading a “weapon” bones data on the character skeleton and using its position as the x/y of the weapon skeleton.
 
M

Maigal

Guest
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)
 
Last edited by a moderator:

rIKmAN

Member
@Maigal
I’m away from home at the moment for the holidays so I dont have access to my dev machine to run any quick tests unfortunately. I’m also typing on an iPad which is horrible so I can’t go into too much detail as I hate typing on a touch screen.

If you’re still struggling when I get back home I’d be happy to chat with you on Discord and work things out, but in the meantime without knowing what you plan to do going forward and to save you waiting around it sounds like it would be easiest for you to use the Spine bbox for your character collision only, and use a separate object/mask for the weapon collision which you can keep aligned using the data from the weapon bone on the skeleton.

You can then run 2 separate collision checks against the the character bbox and the weapon mask separately.

That might be enough for what you need, if not as I said can’t help much until I get home and back to my machine.
 
M

Maigal

Guest
It's ok, i understand the pain of typing on touchscreens D: .
Well honestly i found crappy workarounds for what i'm aiming to do, so now it's a matter of trying to find out best practises and better ways to do stuff, i'm super new in game maker but not new in programming so i can easily realize i'm doing things in a wrong way haha, so i'll be fine for now, maybe in the future i'll ask you about the correct way to do this :p

Thanks a lot for all the help man, i really appreciate it :)
 
Top