• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Windows player getting stuck inside walls

T

TkleinC

Guest
if i turn my player next to a wall he gets stuck inside it, how do i fix it?

bug.PNG

here are my turning codes :
if(hspeed<0)image_angle=180
if(hspeed>0)image_angle=0
if(vspeed<0)image_angle=90
if(vspeed>0)image_angle=270
if(hspeed<0 && vspeed <0) image_angle=135
if(hspeed>0 && vspeed >0) image_angle=315
if(hspeed<0 && vspeed >0) image_angle=225
if(hspeed>0 && vspeed <0) image_angle=45

and here my collision codes :

if hspeed !=0
if !place_free(x+hspeed,y)
{
if hspeed>0 move_contact_solid(0,hspeed)
if hspeed<0 move_contact_solid(180,-hspeed)
hspeed=0
}

if vspeed!=0
if !place_free(x+hspeed,y+vspeed)
{
if vspeed>0 move_contact_solid(270,vspeed)
if vspeed<0 move_contact_solid(90,-vspeed)
vspeed=0
}
 

obscene

Member
You probably need to use a small square and centered sprite for your mask. If you are using a long shape for your mask and then turn, you could be turning your sprite into a wall and then it registers a collision anyway you try to move.

Another option is to prevent turning against a wall. Basically after you turn, run a collision and if it's true, set the angle back to the previous value immediately.
 
Top