T
TheUnsungChampion
Guest
Hello, everyone. Another question for the community. I am in the middle of making my first platformer, and I am having collision problems. Maybe someone here can help, if so, thank you so much in advance.
I am using the following code block to handle collisions. Unfortunately, it isn't working at all; it's acting as if the wall simply isn't there.
if (place_meeting(x, y+vspd, obj_wall))
{
while (!place_meeting(x, y+sign(vspd), obj_solid))
{
y += sign(vspd);
}
vspd = 0;
}
y += vspd;
if (place_meeting(x+hspd, y, obj_wall))
{
while (!place_meeting(x+sign(hspd), y, obj_solid))
{
x += sign(hspd);
}
hspd = 0;
}
x += hspd;
For the record, neither my character nor my "solid" objects has the "solid" flag set, and hspd and vspd are my character's current horizontal and vertical speeds, respectively.
I am using the following code block to handle collisions. Unfortunately, it isn't working at all; it's acting as if the wall simply isn't there.
if (place_meeting(x, y+vspd, obj_wall))
{
while (!place_meeting(x, y+sign(vspd), obj_solid))
{
y += sign(vspd);
}
vspd = 0;
}
y += vspd;
if (place_meeting(x+hspd, y, obj_wall))
{
while (!place_meeting(x+sign(hspd), y, obj_solid))
{
x += sign(hspd);
}
hspd = 0;
}
x += hspd;
For the record, neither my character nor my "solid" objects has the "solid" flag set, and hspd and vspd are my character's current horizontal and vertical speeds, respectively.