Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Wall Detection Doesn't Work For Scrolling Platformer
- creater365
-
Scratcher
100+ posts
Wall Detection Doesn't Work For Scrolling Platformer
I want to make a scrolling platformer, but the issue is the wall detection doesn't work. It seems to for some reason whenever it touches a wall, go straight up it instantly. Even though I added slope and I made it repeat until it's not touching or slope = -8 it still doesn't fix it. Here is the link to the project: https://scratch.mit.edu/projects/413081043/
- secretagent123
-
Scratcher
1000+ posts
Wall Detection Doesn't Work For Scrolling Platformer
I can't actually move in it.
- creater365
-
Scratcher
100+ posts
Wall Detection Doesn't Work For Scrolling Platformer
It's W A S D to move.
- cs2925723
-
Scratcher
100+ posts
Wall Detection Doesn't Work For Scrolling Platformer
I believe the problem may be that the wall is the same sprite as the floor, so when it's touching the wall, it goes up
change y by ((([abs v] of (Y Velocity)) / (Y Velocity)) * (-1)) //Which I THINK this makes it go up.so it ends up at the top.
change y by ((([abs v] of (Y Velocity)) / (Y Velocity)) * (-1)) //Tell me if this doesn't make it go up.
//Because the value of
((([abs v] of (Y Velocity)) / (Y Velocity)) * (-1))
//is one.
- creater365
-
Scratcher
100+ posts
Wall Detection Doesn't Work For Scrolling Platformer
Then how would I add proper wall detection while keeping that in?
- cs2925723
-
Scratcher
100+ posts
Wall Detection Doesn't Work For Scrolling Platformer
Add a different sprite for the wall.
- creater365
-
Scratcher
100+ posts
Wall Detection Doesn't Work For Scrolling Platformer
But I want the level to be all in one sprite.
- Cutie_Pooge
-
Scratcher
500+ posts
Wall Detection Doesn't Work For Scrolling Platformer
You used some bad practices but anyways here I fixed it.
My suggestion, don't use booleans as 1s and 0s, I used to do that 3 years ago, made it annoying to find problems.
The method I used to fix it is just a regular platformer script but it cancels out x velocity in the end and instead adds it to Scroll X
My suggestion, don't use booleans as 1s and 0s, I used to do that 3 years ago, made it annoying to find problems.
The method I used to fix it is just a regular platformer script but it cancels out x velocity in the end and instead adds it to Scroll X
Last edited by Cutie_Pooge (July 23, 2020 16:18:04)
- creater365
-
Scratcher
100+ posts
Wall Detection Doesn't Work For Scrolling Platformer
That wasn't me, I actually used the script from Professor Blue, because I'm pretty bad at making platformers. But thank you anyways.I changed a bit around, and I realized that the repeat until was halting the script for some reason. I didn't know how to fix it.
Last edited by creater365 (July 23, 2020 16:17:49)
- Discussion Forums
- » Help with Scripts
-
» Wall Detection Doesn't Work For Scrolling Platformer