Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do i make a sprite glide to a RANDOM sprite?
- KidThatMakesStuff
-
Scratcher
3 posts
How do i make a sprite glide to a RANDOM sprite?
i am working on a project and it would be really cool if the sprites glide to a random sprite instead of a singular one. 
i have been trying to figure it out for so long. i dont know if it is a skill issue or if it is just really hard.
right now the sprites just glide in random directions.
its not shared yet so uhh yeah, its up and coming. i swear it will be good.
i just cant figure it out. >

i have been trying to figure it out for so long. i dont know if it is a skill issue or if it is just really hard.

right now the sprites just glide in random directions.

its not shared yet so uhh yeah, its up and coming. i swear it will be good.

i just cant figure it out. >

Last edited by KidThatMakesStuff (Dec. 19, 2025 20:12:51)
- kuswerdz
-
Scratcher
100+ posts
How do i make a sprite glide to a RANDOM sprite?
That's a really odd request, what do you intend to use this mechanic for? (please provide a link to the project if you have one)
- Arvionyx
-
New Scratcher
37 posts
How do i make a sprite glide to a RANDOM sprite?
You will have to get a script to choose a random number, and if the number is equal to a value to go a sprite. Here is an example:
Most likely you were just overthinking it. You need to use glide to X y by keeping track of all sprite location in a list that updates every tick and then take that location to glide to. (Or you could just use sensing instead to figure out the distance needed to travel)
when green flag clicked
forever
set [random] to (pick random (1) to (2))
wait (cooldown) secs
end
when green flag clicked
forever
if <[random] = [1]> then
glide (glide speed here) secs to sprite1
if <[random] = [2]> then
glide (glide speed here) secs to sprite2
end
end
Most likely you were just overthinking it. You need to use glide to X y by keeping track of all sprite location in a list that updates every tick and then take that location to glide to. (Or you could just use sensing instead to figure out the distance needed to travel)
Last edited by Arvionyx (Yesterday 00:38:28)
- KidThatMakesStuff
-
Scratcher
3 posts
How do i make a sprite glide to a RANDOM sprite?
Arvionyx, Where would i find the Set () to () block?
- franciscomagic
-
Scratcher
40 posts
How do i make a sprite glide to a RANDOM sprite?
To do that you first need to do a list with the names of the sprites and then randomly pick one name from them:
delete all of [sprite list v]
add [Sprite1] to [sprite list v]
...
when I receive [Go to a sprite v]
glide (1) secs to (item (pick random (1) to (length of [sprite list v] :: list)) of [sprite list v]) :: motion
- Discussion Forums
- » Help with Scripts
-
» How do i make a sprite glide to a RANDOM sprite?