GML My player is stuck on the wall

DPMlofty

Member
He's stuck on the wall, but the collisions and mask are correct what i want to do is just teleport him to the nearest free space
1587503462608.png 1587503444493.png
 
Last edited:

TheouAegis

Member
He's stuck on the wall, but the collisions are correct? Doesn't sound like they are correct.

What's your collision code? What's the diamond around the box?

Also, don't necro/bump old threads. This thread would have been enough.
 

DPMlofty

Member
He's stuck on the wall, but the collisions are correct? Doesn't sound like they are correct.

What's your collision code? What's the diamond around the box?

Also, don't necro/bump old threads. This thread would have been enough.
hi, yes its correct, the blue diamond its just a visual thing, the collisions are correct when he teleports he can enter walls
 

DPMlofty

Member
He's stuck on the wall, but the collisions are correct? Doesn't sound like they are correct.

What's your collision code? What's the diamond around the box?

Also, don't necro/bump old threads. This thread would have been enough.
the collisions are correct when he teleports he can enter walls
 

TheouAegis

Member
But.... You don't want him to actually be in the walls.

So if you code is basically just
Code:
x = mouse_x;
y = mouse_y;
then as was said in the other post, you'll want to loop backwards from (x,y) toward (xprevious,yprevious) to find a free place. For example,
Code:
x = mouse_x;
y = mouse_y;
var dis = point_distance(x,y,xprevious,yprevious),
    dir = point_direction(x,y,xprevious,yprevious);
while dis>0 && place_meeting(x,y,obj_solid) {
        dis--;
        x = xprevious + lengthdir_x(dis,dir);
        y = yprevious + lengthdir_y(dis,dir);
}

Edit: I think the || needed to be &&
 
Last edited:
Top