Legacy GM obj.player stuck in wall when duck sprite is activated

  • Thread starter SonicTheHedgehog+123
  • Start date
S

SonicTheHedgehog+123

Guest
When my player is switching from the normal sprite to the ducking sprite and at the same time is hiting the x axis of the wall he gets stuck. If this happens the player shouldnt be in the wall. He maybe could get a pushback or I could make a invisible wall.
Here is a picture:

Screenshot (12).png

And here is my player duck code:

if keyboard_check(ord("S"))
{
sprite_index = Ducken
}
else
{
sprite_index = Fledermaus_Bild
}
if sprite_index = Ducken
{
hspeed = 0
}


Does somebody know a good solution for this problem?
I would be happy for any response:D
 

Weird Dragon

Wizard
GMC Elder
The reason is probably because the new sprite has a different size, bigger I suppose.
A pushback as you said could be the solution. So just before the code that changes the sprite you could make the player jump back the amount of pixels that makes the difference in size.

Also: Please use the code tags when posting code.
 

gnysek

Member
For sure they have different collision sizes/origins, and that's the cause. One solution is to edit sprites and fix it, better one is to use another sprite as mask, so switching sprites won't affect mask then.
 

Weird Dragon

Wizard
GMC Elder
Well, I didn't think of a mask when I posted my answer. That is a simple solution where you don't need to think of any extra coding.
 
S

SonicTheHedgehog+123

Guest
I did make a smaller collision mask and it works now thank you guys for helping out:p
 
Top