Discuss Scratch

Hamsterdam210
Scratcher
14 posts

sprite follows pen trail

how do i make a sprite go to were the pen was put down and follow the path?
also an example game would be nice.
BigEmster
Scratcher
100+ posts

sprite follows pen trail

https://youtu.be/0faPPgOT–E
You should be able to adapt this to fit that
Hamsterdam210
Scratcher
14 posts

sprite follows pen trail

BigEmster wrote:

https://youtu.be/0faPPgOT–E
You should be able to adapt this to fit that
i cant seem to see the video?
BigEmster
Scratcher
100+ posts

sprite follows pen trail

Weird formatting issue, try this one
https://youtu.be/0faPPgOT–E
Hamsterdam210
Scratcher
14 posts

sprite follows pen trail

BigEmster wrote:

Weird formatting issue, try this one
https://youtu.be/0faPPgOT–E
Idk know if a really understand. This is the game and i want a script for a sprite that follows and goes up the pen trail to the player
.
https://scratch.mit.edu/projects/907413909/

Last edited by Hamsterdam210 (Oct. 14, 2023 03:40:54)

Jaim_animation
Scratcher
94 posts

sprite follows pen trail

You can store the x and y positions where the pen trail is drawn in a list while the pen trail is drawing and then move your sprite to the position! if you want to do it more easier, you can see a pathfinding tutorial:https://www.youtube.com/watch?v=lOs-cldnaN0

Last edited by Jaim_animation (Oct. 14, 2023 06:00:15)

BigEmster
Scratcher
100+ posts

sprite follows pen trail

Use these custom blocks to read and write the path to a list.
define Record Position
if <not <<(x position) = (item (length of [PATH X v]) of [PATH X v])> and <(y position) = (item (length of [PATH Y v]) of [PATH Y v])>>> then
add (x position) to [PATH X v] // This is a new list you will have to create. I use all caps for "for all sprites" variables.
add (y position) to [PATH Y v] // Again, new list for all sprites
comment [The if statement checks if the sprite has moved since the last position was recorded.] :: grey
comment [This way, the follower doesn't pause where the original sprite did. It will cross the path at a constant pace.] :: grey
end
define Follow Path
repeat until <(length of [PATH X v]) = (0)> // PATH X and PATH Y should have the same number of items, so we don't need to check the other one.
go to x: (item (1) of [PATH X v]) y: (item (1) of [PATH Y v])
delete (1) of [PATH X v]
delete (1) of [PATH Y v]
Thanks for the idea Jaim!
Let me know if you're having trouble understanding anything.

Powered by DjangoBB