Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Inconsistency with Wall Bouncing Script
- nman70
-
2 posts
Inconsistency with Wall Bouncing Script
I am adding the mechanic of bouncing off the side of trampolines in my platformer game. I used sensors to the left and right to detect the orange trampoline wall, then to run a bounce script. The sprite can bounce off the right wall just fine, but when I duplicated the script onto the other sensor and replaced all “broadcast (left)”s with “broadcast (right)”, bouncing off the left wall does not work! They're the same script, so how can one work ,but not the other? My project is "Dot's Platformer “ if you would like to see it. The error is on level 9, and the scripts I am referring to are the scripts on ”Sensor Left“ and ”Sensor Right“ and the script on ”Dot“ starting with ”When I receive (bounce)" Thank you for your help!
- drmcw
-
1000+ posts
Inconsistency with Wall Bouncing Script
Wasn't going to play through 9 levels to see what the effect was but just from a quick look at the code. You just use bounce. There is no bounce left or bounce right. I notice you do a multiplication by a minus number so that may cover it, but just wondering if you need to make a distinction between a bounce left or a bounce right?
- nman70
-
2 posts
Inconsistency with Wall Bouncing Script
The interesting thing is that both walls worked fine until I tried to add a zero gravity switch, and although the code for that barely effects the code for bouncing, (the bounce code just tests to see of zero gravity is off before it proceeds) it seems to have broke bouncing off the left wall, but bouncing off the right wall is fine. Also, It seems that when Sensor Left touches the left wall, it doesn't set “current max x vel” to the x velocity, therefore doesn't jump. This seems to be the problem. Wasn't going to play through 9 levels to see what the effect was but just from a quick look at the code. You just use bounce. There is no bounce left or bounce right. I notice you do a multiplication by a minus number so that may cover it, but just wondering if you need to make a distinction between a bounce left or a bounce right?
- Discussion Forums
- » Help with Scripts
-
» Inconsistency with Wall Bouncing Script