D
Dashiello
Guest
[edit] Turns out I checked the 'precise collisions' checkbox on every sprite I made and that was causing some issues. I unchecked most of them and now it works fine!
Hello! This is my first post!
So I'm making a game, and it's going so much better than any other game I've tried to make. Unfortunately, I found a bug that I am unable to fix or really understand.
I was using a modified version of Shaun Spalding's platformer code that allows you to move up and down slopes. However, I tried to change my code so your characters movement had acceleration, and I ran into some bugs.
The bug is very specific, so it'll take some explaining. When standing up against the right of a collision object and jumping, then quickly turning right, the code registers a collision detection. This only happens when you are on the right of a vertical wall, it does not happen when you are on the right. Before, if you turned right it would teleport as far right as was open. I think it has something to do with collision detection being based on your hsp but I really have no idea.
Anyone have any idea what's going on with this? If anyone knows a better way to do movement with acceleration, that would be handy. Thanks!
Movement Code:
Collision Code:
Hello! This is my first post!
So I'm making a game, and it's going so much better than any other game I've tried to make. Unfortunately, I found a bug that I am unable to fix or really understand.
I was using a modified version of Shaun Spalding's platformer code that allows you to move up and down slopes. However, I tried to change my code so your characters movement had acceleration, and I ran into some bugs.
The bug is very specific, so it'll take some explaining. When standing up against the right of a collision object and jumping, then quickly turning right, the code registers a collision detection. This only happens when you are on the right of a vertical wall, it does not happen when you are on the right. Before, if you turned right it would teleport as far right as was open. I think it has something to do with collision detection being based on your hsp but I really have no idea.
Anyone have any idea what's going on with this? If anyone knows a better way to do movement with acceleration, that would be handy. Thanks!
Movement Code:
Code:
move = (key_left + key_right);
//direction
if (move!=0) playerdirection = move;
image_xscale = playerdirection;
//
hsp=clamp(hsp,-global.movespeed,global.movespeed);
hsp += move * global.movespeed/9;
if (move=0)
{
hsp -= sign(hsp)/2;
if(abs(hsp) < 1) hsp=0;
}
if (vsp < fallspeed) vsp += grav;
if (place_meeting(x,y+1,obj_collision))
{
vsp = key_jump * -global.jumpspeed;
}
if (vsp < 0) && (!key_jump_held) vsp*=0.91;
Code:
//Horizontal Collision
if (place_meeting(x+hsp,y,obj_collision))
{
yplus = 0;
while (place_meeting(x+hsp,y-yplus,obj_collision_angle) && yplus <= abs(slopetolerence*hsp)) yplus += 1;
if place_meeting(x+hsp,y-yplus,obj_collision)
{
while(!place_meeting(x+sign(hsp),y,obj_collision))
{
x += sign(hsp);
}
hsp = 0;
}
else
{
y-=yplus;
}
}
else if(!jumping)
{
yplus = abs(slopetolerence*hsp);
while(place_meeting(x+hsp,y+yplus,obj_collision_angle)) && (yplus >0) yplus -=1;
if(!place_meeting(x+hsp,y+yplus,obj_collision))
{
if (place_meeting(x+hsp,y+yplus+1,obj_collision))
{
y+=yplus;
}
}
}
x += hsp;
//Vertical Collision
if (place_meeting(x,y+vsp,obj_collision))
{
while(!place_meeting(x,y+sign(vsp),obj_collision))
{
y += sign(vsp);
}
vsp = 0;
}
y += vsp;
Last edited by a moderator: