Yesterday, I started working on an endless runner in Game maker for practice. Things are going along pretty smoothly, but there's something I caught with the collision.
Basically, whenever the player collides with a floor object from the specific position shown, the game will go into an endless loop.
Here is the collision code that I have in the player's step event:
if (place_meeting(x,y+vsp,obj_floor)){
while(!place_meeting(x,y+sign(vsp),obj_floor)){
y += sign(vsp);
}
vsp = 0;
}
while (place_meeting(x,y,obj_floor)){
x -= global.playerspeed;
y += global.playerspeed;
}
Any help or advice would be greatly appreciated! :D
please edit your question and add some comments to your code so we know what your functions and objects are. Im guessing that
just a hiccup in your logic you want this function:
while (place_meeting(x,y,obj_floor)){
x -= global.playerspeed;
y += global.playerspeed;
to run every frame. so you need to increment the speed, let that update the characters position then check again. just adding a break statement might fix it but you probably shouldn't use a while loop
.while (place_meeting(x,y,obj_floor)){
x -= global.playerspeed;
y += global.playerspeed;
break;
or
if(place_meeting(x,y,obj_floor)// collision detected
{
x -= speed; //player moves backwards away from object
y += speed; // player moves up;
}else{//no collision
x+= speed; // player moves along
}
PS. sorry if i made syntax error i mostly use c++, been a while since i used GM