Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » NEED HELP WITH SLOPES
- krnickey
-
Scratcher
100+ posts
NEED HELP WITH SLOPES
when you drop while theres a platform like really close under you it snaps to that platform and i dont want that it looks really bad
link: https://scratch.mit.edu/projects/1370298362/
also the slope controller is inside the move plrX block
specifing which code to look for:

sorry I cant explain this better
link: https://scratch.mit.edu/projects/1370298362/
also the slope controller is inside the move plrX block
specifing which code to look for:

sorry I cant explain this better
Last edited by krnickey (Aug. 22, 2026 10:54:53)
- krnickey
-
Scratcher
100+ posts
NEED HELP WITH SLOPES
its a bump for like bumping the post for others to see itbum.pWhat Did You Say?
look it up
- 102acrimea
-
Scratcher
100+ posts
NEED HELP WITH SLOPES
Simple fix is to reduce the initial change .Py and the else change .Py to a lower number, after some testing i would recommend 10.
However if you want it to follow a more specific behavior such as detecting if it is a slope or not and not snapping if it is not a slope, it would require a bit more code and i can elaborate further
However if you want it to follow a more specific behavior such as detecting if it is a slope or not and not snapping if it is not a slope, it would require a bit more code and i can elaborate further
- krnickey
-
Scratcher
100+ posts
NEED HELP WITH SLOPES
Simple fix is to reduce the initial change .Py and the else change .Py to a lower number, after some testing i would recommend 10.I mean I want to keep the values I just need to have it detecting if its a slope
However if you want it to follow a more specific behavior such as detecting if it is a slope or not and not snapping if it is not a slope, it would require a bit more code and i can elaborate further
Last edited by krnickey (Aug. 22, 2026 11:09:11)
- 102acrimea
-
Scratcher
100+ posts
NEED HELP WITH SLOPES
Could do that, a little bit more complex however.
Firstly, you need to make a new myBlock (something along the lines of slopeDetect), what the block does it test the current position and the Y position of the ground, move a little bit left and right and get their ground Y value, then get those values and check if their differences indicate a slope (a certain rate of change). Before returning to the original position to decide whether to snap or not
I can make scratchblocks to elaborate for this to post into the forum but it takes a bit so lmk if you want that
Firstly, you need to make a new myBlock (something along the lines of slopeDetect), what the block does it test the current position and the Y position of the ground, move a little bit left and right and get their ground Y value, then get those values and check if their differences indicate a slope (a certain rate of change). Before returning to the original position to decide whether to snap or not
I can make scratchblocks to elaborate for this to post into the forum but it takes a bit so lmk if you want that
- krnickey
-
Scratcher
100+ posts
NEED HELP WITH SLOPES
Could do that, a little bit more complex however.yeah I need scratch blocks I cant understand what you're saying, sorry
Firstly, you need to make a new myBlock (something along the lines of slopeDetect), what the block does it test the current position and the Y position of the ground, move a little bit left and right and get their ground Y value, then get those values and check if their differences indicate a slope (a certain rate of change). Before returning to the original position to decide whether to snap or not
I can make scratchblocks to elaborate for this to post into the forum but it takes a bit so lmk if you want that
- 102acrimea
-
Scratcher
100+ posts
NEED HELP WITH SLOPES
Using your collisioncheck myblock
This likely won't look good on first post, may also contain bugs
Note that it is not perfect either and may require some tweaking to meet your requirements
Script breakdown:
To use this, place this before your snapping script and add an additional requirement to snap (besides falling = 0) that is snap = 0
This script works by checking how far down the ground is to the right, then beneath the original position, then to the left, before checking if any values are equal. If any values are equal, that indicates the player is not on a slope and should not snap
This likely won't look good on first post, may also contain bugs
Note that it is not perfect either and may require some tweaking to meet your requirements
when green flag clicked
delete all of [slopeData v]
define groundTest
set [touch v] to [0]
repeat (50)
if <[touch] = [0]> then
change [.Py v] by (-1)
collisioncheck
else
add [.Py] to [slopeData v]
stop [this script v]
end
end
set [snap v] to [0]
define slopeCheck
delete all of [slopeData v]
set [snap v] to (1)
set [oldX v] to (.Px)
set [oldY v] to (.Py)
change [.Px v] by (5)
groundTest
set [.Px v] to [oldX]
set [.Py v] to [oldY]
groundTest
set [.Px v] to [oldX]
set [.Py v] to [oldY]
change [.Px v] by (-5)
groundTest
set [.Px v] to [oldX]
set [.Py v] to [oldY]
if <<not <(item (1 v) of [slopeData v] :: list) = (item (2 v) of [slopeData v] :: list)>> and <<not <(item (2 v) of [slopeData v] :: list) = (item (3 v) of [slopeData v] :: list)>> and <not <(item (1 v) of [slopeData v] :: list) = (item (3 v) of [slopeData v] :: list)>>>> then
else
set [snap v] to [0]
end
Script breakdown:
To use this, place this before your snapping script and add an additional requirement to snap (besides falling = 0) that is snap = 0
This script works by checking how far down the ground is to the right, then beneath the original position, then to the left, before checking if any values are equal. If any values are equal, that indicates the player is not on a slope and should not snap
Last edited by 102acrimea (Aug. 22, 2026 11:35:23)
- krnickey
-
Scratcher
100+ posts
NEED HELP WITH SLOPES
bump because I need a more simpler and more effective way
https://scratch.mit.edu/projects/1370298362/
https://scratch.mit.edu/projects/1370298362/
- 10goto10
-
Scratcher
1000+ posts
NEED HELP WITH SLOPES
Concerning slope detection and sliding down the slope. I've added a couple of small hit blocks that seem to work okay to detect slopes. my remix is here https://scratch.mit.edu/projects/1374428325/
I'm not sure what to say if this isn't what you are looking for. Sometimes you just reach an end point to what you are trying to do in Scratch.
I'm not sure what to say if this isn't what you are looking for. Sometimes you just reach an end point to what you are trying to do in Scratch.
- Discussion Forums
- » Help with Scripts
-
» NEED HELP WITH SLOPES