Discuss Scratch

dougconran
New Scratcher
6 posts

Sprites keep falling through floating platform (created as sprite)

I'm new to Scratch but am struggling to stop my player sprite falling through a floating platform. At the moment I do not know how to search this forum for any answers (some guidance would be much appreciated) but googling the issue I've found a number of posts describing the problem but no workable solutions. It is nothing to do with the player inadvertently touching the platform because I have forced it well above that. It only seems to happen when the player is stationary on/over the platform and, generally, there is a finite pause of at least a few tenths of a second. Also, this only occurs on floating platforms not those that stretch down to the base of the ground sprite.

Any help/suggestions/workarounds would be much appreciated (as would help on how to search this forum)
meepeygamer567
Scratcher
500+ posts

Sprites keep falling through floating platform (created as sprite)

A link would help.
g4tor2010
Scratcher
100+ posts

Sprites keep falling through floating platform (created as sprite)

I'm not going to be too hard on you since it's the first time, you can post script-related question here. I think you can use:



The simple explanation is that the character moves -5 steps whenever it encounters the ground. But the movement is so quick and small that you can't see it. Here's a pretty decent project that has this.
OhOkSir12345
Scratcher
1000+ posts

Sprites keep falling through floating platform (created as sprite)

g4tor2010 wrote:

I'm not going to be too hard on you since it's the first time, you can post script-related question here. I think you can use:



The simple explanation is that the character moves -5 steps whenever it encounters the ground. But the movement is so quick and small that you can't see it. Here's a pretty decent project that has this.
...::#808080
if <touching color (insert color of ground here)?> then
move (-5) steps
end
g4tor2010
Scratcher
100+ posts

Sprites keep falling through floating platform (created as sprite)

OhOkSir12345 wrote:

g4tor2010 wrote:

I'm not going to be too hard on you since it's the first time, you can post script-related question here. I think you can use:



The simple explanation is that the character moves -5 steps whenever it encounters the ground. But the movement is so quick and small that you can't see it. Here's a pretty decent project that has this.
...::#808080
if <touching color (insert color of ground here)?> then
move (-5) steps
end
Isn't that exactly what I just said?
OhOkSir12345
Scratcher
1000+ posts

Sprites keep falling through floating platform (created as sprite)

g4tor2010 wrote:

OhOkSir12345 wrote:

g4tor2010 wrote:

I'm not going to be too hard on you since it's the first time, you can post script-related question here. I think you can use:



The simple explanation is that the character moves -5 steps whenever it encounters the ground. But the movement is so quick and small that you can't see it. Here's a pretty decent project that has this.
...::#808080
if <touching color (insert color of ground here)?> then
move (-5) steps
end
Isn't that exactly what I just said?
yes but it is smaller and 2.0
g4tor2010
Scratcher
100+ posts

Sprites keep falling through floating platform (created as sprite)

Isn't larger easier to see?
dougconran
New Scratcher
6 posts

Sprites keep falling through floating platform (created as sprite)

Thanks for a very quick answer but I've already tried that without success. I've forced it up to 10 pixels above the surface but it still drops down, not immediately but after a few tenths of a second. If I continually jump the player then it stays on the floating surface but as soon as I stop, after a short pause it drops through to the base surface. To me that implies that it is not the ‘not touching the surface’ that is the problem but some other issue.
han614698
Scratcher
1000+ posts

Sprites keep falling through floating platform (created as sprite)

dougconran wrote:

Thanks for a very quick answer but I've already tried that without success. I've forced it up to 10 pixels above the surface but it still drops down, not immediately but after a few tenths of a second. If I continually jump the player then it stays on the floating surface but as soon as I stop, after a short pause it drops through to the base surface. To me that implies that it is not the ‘not touching the surface’ that is the problem but some other issue.
I don’t think that their code will work, because, if I’m assuming correctly, you want the sprite to fall and then sit on a platform?
The code given by g4ator2010 will just move it 5 pixels

——>

This way, when you need to move

î

This way.

Replace the move (5) steps block with a
change y by (5)

Last edited by han614698 (Oct. 26, 2021 21:56:42)

dougconran
New Scratcher
6 posts

Sprites keep falling through floating platform (created as sprite)

Thank you, all, for your suggestions. Given that the issue had cropped up several times a few years ago I was hoping that there was an easy fix but, apoarently not. On reflection, given the small delay between landing on the surface and falling through it I'm beginning to think that it may be an issue with the last part of code in the forever loop. I need to do some more and different testing.
cheddargirl
Scratch Team
1000+ posts

Sprites keep falling through floating platform (created as sprite)

Don't mind me, I'm just dropping a message to let you know I moved your topic over to the correct section so more eyes can see the topic (though I would have to agree with meepeygamer567 that a link would help - that way we all can see the code and give further suggestions on how to improve the script).
dougconran
New Scratcher
6 posts

Sprites keep falling through floating platform (created as sprite)

cheddargirl wrote:

Don't mind me, I'm just dropping a message to let you know I moved your topic over to the correct section so more eyes can see the topic (though I would have to agree with meepeygamer567 that a link would help - that way we all can see the code and give further suggestions on how to improve the script).
Unfortunately I am running Scratch as a local app, not on the internet, and cannot find any way of being able to upload the project - is there a way to do that?
dougconran
New Scratcher
6 posts

Sprites keep falling through floating platform (created as sprite)

Ah, okay, I've just discovered how to do that (create an internet project and upload my file to that). The link is :-

https://scratch.mit.edu/projects/590598883/editor
meepeygamer567
Scratcher
500+ posts

Sprites keep falling through floating platform (created as sprite)

Did you remember to share?
SansStudios
Scratcher
1000+ posts

Sprites keep falling through floating platform (created as sprite)

Welcome to the forums!

Your issue happens because you never reset velocity after touching the ground. You can simply add this at the bottom of your test falling block:

if <touching [Level1 v] ?> then
...
set [velocity v] to [0] // add this block!
end

Last edited by SansStudios (Oct. 28, 2021 00:18:34)

CrownIR1
Scratcher
100+ posts

Sprites keep falling through floating platform (created as sprite)

SansStudios wrote:

Welcome to the forums!

Your issue happens because you never reset velocity after touching the ground. You can simply add this at the bottom of your test falling block:

if <touching [Level1 v] ?> then
...
set [velocity v] to [0] // add this block!
end
ah, but you see, you are forgetting the side of the platform.
SansStudios
Scratcher
1000+ posts

Sprites keep falling through floating platform (created as sprite)

CrownIR1 wrote:

ah, but you see, you are forgetting the side of the platform.

This user's game has code that causes a game over screen if you touch the side of the platform, so it's irrelevant in this situation. Good catch though!

Last edited by SansStudios (Oct. 28, 2021 00:28:36)

dougconran
New Scratcher
6 posts

Sprites keep falling through floating platform (created as sprite)

SansStudios wrote:

Welcome to the forums!

Your issue happens because you never reset velocity after touching the ground. You can simply add this at the bottom of your test falling block:

if <touching [Level1 v] ?> then
...
set [velocity v] to [0] // add this block!
end
Brilliant! Many thanks for the suggestion
SansStudios
Scratcher
1000+ posts

Sprites keep falling through floating platform (created as sprite)

Glad I could help!

Powered by DjangoBB