yashamatt
Member
So I have a beginner-style collision code set up and I either want to improve it to avoid bugs or develop some sort of work-around so that if bugs occur the player isn't perpetually stuck in a collision object. I kind of need some help brainstorming a solution.
Due to dealing with a scope that's slightly larger than my ability to code I manage to get my character stuck in my collision objects, though very rarely (I pretty much have to try to clip in on purpose), but still more often than I feel a decent game should allow (eg for reference it does it more often than release-date Skyrim).
I remember playing some games where if you manage to clip collision objects and get stuck the player gets pushed slowly out of the object towards the edge closest to the player object's origin. This would be a pretty nice solution but I'm not exactly sure how I would go about doing it.
I have also looked into the collision_line functions and want to convert my current collision code to use these because I've heard they're better to use but I still haven't figured it out properly yet, and clipping may still occur (right?).
I don't think it's a problem with masks because I use the one default mask between sprites/states.
the game is a 2d platformer.
my current code is:
if !place_meeting(x + xSpeed, y, par_solid){
x += xSpeed;
}
if place_meeting(x + xSpeed, y, par_solid){
while !place_meeting(x + sign(xSpeed), y, par_solid){
x += sign(xSpeed);
}
xSpeed = 0;
}
if !place_meeting(x, y + ySpeed, par_solid){
y += ySpeed;
}
if place_meeting(x, y + ySpeed, par_solid){
while !place_meeting(x, y + sign(ySpeed), par_solid){
y += sign(ySpeed);
}
ySpeed = 0;
}
Due to dealing with a scope that's slightly larger than my ability to code I manage to get my character stuck in my collision objects, though very rarely (I pretty much have to try to clip in on purpose), but still more often than I feel a decent game should allow (eg for reference it does it more often than release-date Skyrim).
I remember playing some games where if you manage to clip collision objects and get stuck the player gets pushed slowly out of the object towards the edge closest to the player object's origin. This would be a pretty nice solution but I'm not exactly sure how I would go about doing it.
I have also looked into the collision_line functions and want to convert my current collision code to use these because I've heard they're better to use but I still haven't figured it out properly yet, and clipping may still occur (right?).
I don't think it's a problem with masks because I use the one default mask between sprites/states.
the game is a 2d platformer.
my current code is:
if !place_meeting(x + xSpeed, y, par_solid){
x += xSpeed;
}
if place_meeting(x + xSpeed, y, par_solid){
while !place_meeting(x + sign(xSpeed), y, par_solid){
x += sign(xSpeed);
}
xSpeed = 0;
}
if !place_meeting(x, y + ySpeed, par_solid){
y += ySpeed;
}
if place_meeting(x, y + ySpeed, par_solid){
while !place_meeting(x, y + sign(ySpeed), par_solid){
y += sign(ySpeed);
}
ySpeed = 0;
}