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

Question - Code Spine animation collision issue

J

Justinbaileynes1987!

Guest
I dont know about you guys but when i import spine animations into game maker 2 the collision system gets wonky. I have a bounding box but it doesn't seem to use it and setting the collision mask to another sprite does nothing. i have a script written to stop the object right before it hits a wall but it gets stuck inside if i use my spine json as its sprite.
 
S

SolariumScum

Guest
Did you fix this by chance? For some reason my Player object woks great with the collisions, but when applying the same concepts/code to my enemies they get stuck in the walls and or pass through one side or the other.

var xx,yy,c1,c2;





if(dir == -1) // if moving left
{ image_xscale = 1;
{

if skeleton_animation_get() != "walk"
{
skeleton_animation_set("walk");

}
}

c1 = -1; // reset the collision tile checkers
c2 = -1;
c1 = tilemap_get_at_pixel(oGame.map, x, y); // check the left edge of the sprite
c2 = tilemap_get_at_pixel(oGame.map,x,y+sprite_height); // check below the left edge of the sprite, since ghosts dont like heights
if ((c1 >= 1) || (c2 <= 0)){ // if there is something blocking the left or if there would be a fall to the left
x = (x&$ffffffc0)+sprite_width; // move the object to the edge of the tile
dir *= -1;
// change the direction
}
}

else{ if(dir == 1) // if moving right
{ image_xscale = -1;

{

if skeleton_animation_get() != "walk"
{
skeleton_animation_set("walk");

}
} // set the correct direction
// set the correct direction
} // animation to play
// default speed of the animation
// set the sprite to point the correct way
c1 = -1; // reset the collision tile checkers
c2 = -1;
c1 = tilemap_get_at_pixel(oGame.map,x+sprite_width,y); // check the right edge of the sprite
c2 = tilemap_get_at_pixel(oGame.map,x+sprite_width,y+sprite_height); // check below the right edge of the sprite, since ghosts dont like heights
if((c1 <= 1) || (c2 <= -1)){ // if there is something blocking the right or if there would be a fall to the right
x = (x&$ffffffc0);
// move the object to the edge of the tile || $ffffffc0 rounds the position to the nearest 64
dir *= -1;
// change the direction
}
}
 
J

Justinbaileynes1987!

Guest
Did you fix this by chance? For some reason my Player object woks great with the collisions, but when applying the same concepts/code to my enemies they get stuck in the walls and or pass through one side or the other.

var xx,yy,c1,c2;





if(dir == -1) // if moving left
{ image_xscale = 1;
{

if skeleton_animation_get() != "walk"
{
skeleton_animation_set("walk");

}
}

c1 = -1; // reset the collision tile checkers
c2 = -1;
c1 = tilemap_get_at_pixel(oGame.map, x, y); // check the left edge of the sprite
c2 = tilemap_get_at_pixel(oGame.map,x,y+sprite_height); // check below the left edge of the sprite, since ghosts dont like heights
if ((c1 >= 1) || (c2 <= 0)){ // if there is something blocking the left or if there would be a fall to the left
x = (x&$ffffffc0)+sprite_width; // move the object to the edge of the tile
dir *= -1;
// change the direction
}
}

else{ if(dir == 1) // if moving right
{ image_xscale = -1;

{

if skeleton_animation_get() != "walk"
{
skeleton_animation_set("walk");

}
} // set the correct direction
// set the correct direction
} // animation to play
// default speed of the animation
// set the sprite to point the correct way
c1 = -1; // reset the collision tile checkers
c2 = -1;
c1 = tilemap_get_at_pixel(oGame.map,x+sprite_width,y); // check the right edge of the sprite
c2 = tilemap_get_at_pixel(oGame.map,x+sprite_width,y+sprite_height); // check below the right edge of the sprite, since ghosts dont like heights
if((c1 <= 1) || (c2 <= -1)){ // if there is something blocking the right or if there would be a fall to the right
x = (x&$ffffffc0);
// move the object to the edge of the tile || $ffffffc0 rounds the position to the nearest 64
dir *= -1;
// change the direction
}
}
not really but i did figure out to use the correct spine run time for game maker (i think its 3.4.02) with this your able to have a regular sprite be the mask. what i do is make sure the width is an odd number so when the sprite flips it doesnt get stuck in things shaun spalding has a good video about why that happens in his old platformer videos for game maker 1.4 so for example if your sprite is 32x32 make it 33x32 so it flips right in the middle. oh if your going to use another collison mask its best not to setup a bounding box but if you want one only set one.
 
S

SolariumScum

Guest
not really but i did figure out to use the correct spine run time for game maker (i think its 3.4.02) with this your able to have a regular sprite be the mask. what i do is make sure the width is an odd number so when the sprite flips it doesnt get stuck in things shaun spalding has a good video about why that happens in his old platformer videos for game maker 1.4 so for example if your sprite is 32x32 make it 33x32 so it flips right in the middle. oh if your going to use another collison mask its best not to setup a bounding box but if you want one only set one.
I actually got it working last night! Put a collision box on the Main ROOT bone as, I just needed it simple for now, also set the sprite itself to PRECISE.
When you put in this line of code in the draw event....just make sure you replace --sprite_index-- with the correct name of your sprite and nothing else seems to really matter much to get it to display....other colors on the --C_white-- didnt seem to change when i made it green though but does't matter to me happy its working:

---( draw_skeleton_collision(sprite_index, "jump", image_index, x, y, image_xscale, image_yscale, image_angle, c_white); ---


It will display the full collision with your chosen color of collision box,helps to see it really helps a lot! After that just gotta get your collision code to function, detecting tiles and or solids. The one and only weird issue is my enemies are hitting the opposite side of the collision items...Walls/Crates ect....they're passing through the Crates, but do hit the wrong side and come back. Also got some awesome random AI chosen movement at random intervals down! Like 2D AI.

I really feel so accomplished having never written code or made a game first time ever progress is phenomenal !
 
S

SolariumScum

Guest
3.4.02 is the latest functional for sure... I wish there was more info out there so few videos and hard to decipher exactly whats required sometimes out of the Spine and Game Make manuals, when it gets technical with Spine assets. If I knew more I'd Probably make an e-Book or somthin...lot of people with a lot of questions.
 
J

Justinbaileynes1987!

Guest
also check the spine forums the devs for spine are more than happy to help people out
 

rIKmAN

Member
3.4.02 is the latest functional for sure... I wish there was more info out there so few videos and hard to decipher exactly whats required sometimes out of the Spine and Game Make manuals, when it gets technical with Spine assets. If I knew more I'd Probably make an e-Book or somthin...lot of people with a lot of questions.
If you search the forum for "Spine" and/or my username, I've made a few posts listing the gotchas and caveats of using Spine with GMS, things you need to do, things to avoid etc.

You are right though, it would probably be a good idea to collate them into one post / place so all the various issues are easy to find as I agree the manual / docs for Spine in GMS are pretty poor.

also check the spine forums the devs for spine are more than happy to help people out
They are good guys on the official forum, but because the GMS runtime is integrated into the GMS black box (and not using one of the standard official runtimes "as-is") they usually tell people to ask the YYG devs as they don't have access to the integration code so can't really advise on anything more than Spine usage itself.
 
Top