K
kingjabu
Guest
Right, so in my game, I'm going the pretty standard method with collision, and this is the code I'm using
My question is, how would I go about making the player "slide" across the bottom of a block rather than setting vsp back to 0 making him fall? I want to hold position until the player falls naturally.
Just to try to visualize what I mean:
So the vsp is set to 0 upon collision, that's what I want to do for the top of course to prevent the player from falling through, however for the bottom, I want the player to slide across until gravity
has an effect on vertical speed. Something like this:
Any help is much appreciated!
Code:
if(grid_meeting(x, y + vsp, foreground)) {
if(!grid_meeting(x, y + sign(vsp), foreground)) {
y += sign(vsp);
}
vsp = 0;
}
y += vsp;
Just to try to visualize what I mean:
So the vsp is set to 0 upon collision, that's what I want to do for the top of course to prevent the player from falling through, however for the bottom, I want the player to slide across until gravity
has an effect on vertical speed. Something like this:
Any help is much appreciated!