R
RossDear
Guest
Hi GameMaker Community!
So I'm having some troubles with collisions detection.
I'm using some basic code to make my walls tangible:
My issue is that the player will sometime goes to great speeds, so he might end up in a wall or even going directly throw it.
I guess it could be solved by comparing the position at the frame X and check if it will be in a wall at the distance corresponding to the frame X+1 and then reducing the speed to goes against the wall.
I might be overanalyzing that stuff. Is there an easier way to do that?
So I'm having some troubles with collisions detection.
I'm using some basic code to make my walls tangible:
Code:
//Horizontal Collision (ok)
if (place_meeting(x+hsp,y,obj_wall))
{
while (!place_meeting(x+sign(hsp),y,obj_wall))
{
x = x + sign(hsp);
}
hsp=0;
}
x = x + hsp;
//Vertical Collision (ok)
if (place_meeting(x,y+vsp,obj_wall))
{
while (!place_meeting(x,y+sign(vsp),obj_wall))
{
y = y + sign(vsp);
}
vsp=0;
}
y = y + vsp;
I guess it could be solved by comparing the position at the frame X and check if it will be in a wall at the distance corresponding to the frame X+1 and then reducing the speed to goes against the wall.
I might be overanalyzing that stuff. Is there an easier way to do that?