Discuss Scratch

Jedi_Edrich
Scratcher
11 posts

script to keep sprite on a moving platform?

Does anyone know a simple script to keep a sprite on a moving platform. Not looking for something overly complicated. Thanks!
wkelly42
Teacher
100+ posts

script to keep sprite on a moving platform?

Assuming that the platform moves 1, do this:
iftouchingplatform?thenmove1steps
Basically, all you do is make sure that the sprite moves the same as the platform as long as it's touching the platform. That's what I did in my Frogger clone (https://scratch.mit.edu/projects/56306968/). This way, you can move OFF the platform once you're on it.
JSE2001
Scratcher
100+ posts

script to keep sprite on a moving platform?

Jedi_Edrich wrote:

Does anyone know a simple script to keep a sprite on a moving platform. Not looking for something overly complicated. Thanks!

Maybe you can do this: (make sure you have slope detection in you platforming script)

foreveriftouchingmoving platform?thensetxtox positionofmoving platform
Jedi_Edrich
Scratcher
11 posts

script to keep sprite on a moving platform?

Thanks for the tips - I will try these.
Finnthebest12
Scratcher
100+ posts

script to keep sprite on a moving platform?

try this

whenclickedforeveriftouchingplatform?thengotoplatform

Last edited by Finnthebest12 (July 16, 2015 14:41:42)

JSE2001-TEST
Scratcher
12 posts

script to keep sprite on a moving platform?

Did you see the link I posted on your profile? There is a working version of the script, please look!
Specter22
Scratcher
100+ posts

script to keep sprite on a moving platform?

Check out Shaun's Platform Game https://scratch.mit.edu/projects/21899025/ it has moving platforms.
Check out the whole course.
Arlo55
Scratcher
1 post

script to keep sprite on a moving platform?

uygv77tvy
gtoal
Scratcher
1000+ posts

script to keep sprite on a moving platform?

Jedi_Edrich wrote:

Does anyone know a simple script to keep a sprite on a moving platform. Not looking for something overly complicated. Thanks!
is the platform moving up and down, or sideways like a conveyor belt?

in any case, whatever x/y delta is being applied to the platform, the same offset should be applied to the player assuming it is touching the platform. taking care to move the character in the same refresh cycle as the platform, before both are drawn together. (to avoid jittering)
Pancake_Boy616
Scratcher
6 posts

script to keep sprite on a moving platform?

JSE2001 wrote:

Jedi_Edrich wrote:

Does anyone know a simple script to keep a sprite on a moving platform. Not looking for something overly complicated. Thanks!

Maybe you can do this: (make sure you have slope detection in you platforming script)

foreveriftouchingmoving platform?thensetxtox positionofmoving platform
nope doent work on scratch 3.0
best-games-ever
Scratcher
500+ posts

script to keep sprite on a moving platform?

Pancake_Boy616 wrote:

JSE2001 wrote:

Jedi_Edrich wrote:

Does anyone know a simple script to keep a sprite on a moving platform. Not looking for something overly complicated. Thanks!

Maybe you can do this: (make sure you have slope detection in you platforming script)

foreveriftouchingmoving platform?thensetxtox positionofmoving platform
nope doent work on scratch 3.0
Please don't Necropost
DerpyHead0
Scratcher
1000+ posts

script to keep sprite on a moving platform?

Pancake_Boy616 wrote:

nope doent work on scratch 3.0
this topic is from 2017, if you are having issues, make a new topic.
also, every script can only work when it's put in the right place. are you sure it's in the correct loop, in the right sprite, and that this is what you need for your situation?

i assume the problem is that your platform moves up and down, is using some costume movement setup, or your player isn't colliding with it correctly.
hoi_man
New Scratcher
1 post

script to keep sprite on a moving platform?

who says no necro posting lol
677784A
Scratcher
8 posts

script to keep sprite on a moving platform?

hoi_man wrote:

who says no necro posting lol
everyone exept you

Last edited by 677784A (June 7, 2020 00:00:55)

balmerazTSC
Scratcher
26 posts

script to keep sprite on a moving platform?

to make it so it doesn't teleport to the middle of the platform, you could do this:
iftouchingmoving platform?thensetxtoX posofmoving plat. -xposition+X posofmoving plat.

You can get the
X posofSprite1
block from old projects, and backpack it. here is a project that I made that has that block:
https://scratch.mit.edu/projects/414840806/editor/
cavemanster
Scratcher
100+ posts

script to keep sprite on a moving platform?

make a variable called “resting x speed” set this to zero if you aren't on a moving platform and set this to the speed of the moving platform you are on (if you are on a moving platform.) Now, for all the movement scripts along the X axis, instead of changing the x by a certain amount, change the x by the wanted amount + resting x speed.
ScratchCatHELLO
Scratcher
1000+ posts

script to keep sprite on a moving platform?

Arlo55 wrote:

uygv77tvy

gtoal wrote:

Jedi_Edrich wrote:

Does anyone know a simple script to keep a sprite on a moving platform. Not looking for something overly complicated. Thanks!
is the platform moving up and down, or sideways like a conveyor belt?

in any case, whatever x/y delta is being applied to the platform, the same offset should be applied to the player assuming it is touching the platform. taking care to move the character in the same refresh cycle as the platform, before both are drawn together. (to avoid jittering)

Pancake_Boy616 wrote:

JSE2001 wrote:

Jedi_Edrich wrote:

Does anyone know a simple script to keep a sprite on a moving platform. Not looking for something overly complicated. Thanks!

Maybe you can do this: (make sure you have slope detection in you platforming script)

foreveriftouchingmoving platform?thensetxtox positionofmoving platform
nope doent work on scratch 3.0

hoi_man wrote:

who says no necro posting lol

balmerazTSC wrote:

to make it so it doesn't teleport to the middle of the platform, you could do this:
iftouchingmoving platform?thensetxtoX posofmoving plat. -xposition+X posofmoving plat.

You can get the
X posofSprite1
block from old projects, and backpack it. here is a project that I made that has that block:
https://scratch.mit.edu/projects/414840806/editor/

cavemanster wrote:

make a variable called “resting x speed” set this to zero if you aren't on a moving platform and set this to the speed of the moving platform you are on (if you are on a moving platform.) Now, for all the movement scripts along the X axis, instead of changing the x by a certain amount, change the x by the wanted amount + resting x speed.


Guys. This post is from 2015. Please stop necroposting.


DerpyHead0 wrote:

Pancake_Boy616 wrote:

nope doent work on scratch 3.0
this topic is from 2017, if you are having issues, make a new topic.
also, every script can only work when it's put in the right place. are you sure it's in the correct loop, in the right sprite, and that this is what you need for your situation?

i assume the problem is that your platform moves up and down, is using some costume movement setup, or your player isn't colliding with it correctly.


*2015

.
balmerazTSC
Scratcher
26 posts

script to keep sprite on a moving platform?

HELLO!!!Highfive
joshuaho
Scratcher
1000+ posts

script to keep sprite on a moving platform?

Hey folks - thanks for helping out! However, this topic is old (from 2015) - so I doubt the topic owner is still looking for answers. I would suggest looking for newer threads (that still need to be answered) and respond to those instead.
CoolCrafter1231
Scratcher
100+ posts

script to keep sprite on a moving platform?

Finnthebest12 wrote:

try this

whenclickedforeveriftouchingplatform?thengotoplatform
this would the character to go straight to the platform and trap the player in the platform

Powered by DjangoBB