Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How can I prevent/remove wall snagging
- CanineData
-
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!
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
-
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-
-
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
-
26 posts
How can I prevent/remove wall snagging
Thanks! This worked wonders for me, now I just need to improve the render function to make the walls actually smooth. 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
-
26 posts
How can I prevent/remove wall snagging
Thank you, this also worked for an issue where it would sometimes just move into the wall a bit 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.
- Discussion Forums
- » Help with Scripts
-
» How can I prevent/remove wall snagging