Discuss Scratch

CanineData
Scratcher
26 posts

How can I prevent/remove wall snagging

Currently in my project whenever you hit a wall you come to a complete stop. What I want is that you're movement just levels out and goes in a straight line to follow the wall.

I've already tried splitting the X and Y move functions, but that didn't work for some reason.

Project Link: https://scratch.mit.edu/projects/909847484/editor/
Thanks in advance for any help!
standing_rake
Scratcher
55 posts

How can I prevent/remove wall snagging

Curving the corners of your hitbox sprite seems to make it better, even if it doesn't fix it. Maybe even make your hitbox a circle. What's happening is when you turn, the corners of the square get stuck, so a circle might work better.

Last edited by standing_rake (Nov. 3, 2023 23:51:36)

-TUB-
Scratcher
100+ posts

How can I prevent/remove wall snagging

It seems that your code is fine if the level is stationary, but the player can get snagged against walls when the level is scrolling. This might be due to the position being shifted by a non-integer amount, leading to inconsistent color collisions. Using a round block in the movement code to keep the position as an integer seemed to fix this issue for me.
CanineData
Scratcher
26 posts

How can I prevent/remove wall snagging

-TUB- wrote:

It seems that your code is fine if the level is stationary, but the player can get snagged against walls when the level is scrolling. This might be due to the position being shifted by a non-integer amount, leading to inconsistent color collisions. Using a round block in the movement code to keep the position as an integer seemed to fix this issue for me.
Thanks! This worked wonders for me, now I just need to improve the render function to make the walls actually smooth.
CanineData
Scratcher
26 posts

How can I prevent/remove wall snagging

standing_rake wrote:

Curving the corners of your hitbox sprite seems to make it better, even if it doesn't fix it. Maybe even make your hitbox a circle. What's happening is when you turn, the corners of the square get stuck, so a circle might work better.
Thank you, this also worked for an issue where it would sometimes just move into the wall a bit

Powered by DjangoBB