R
Rob86
Guest
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:
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
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
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