Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » have a sprite follow another sprite, like in RPGs
- Mr_PenguinAlex
- Scratcher
1000+ posts
have a sprite follow another sprite, like in RPGs
https://scratch.mit.edu/projects/572796812/
I can't figure out how to make a sprite follow the player like in an RPG.
I can't figure out how to make a sprite follow the player like in an RPG.
- Wei-ern_520
- Scratcher
500+ posts
have a sprite follow another sprite, like in RPGs
https://scratch.mit.edu/projects/572796812/Is it scrolling?
I can't figure out how to make a sprite follow the player like in an RPG.
Please consider checking out my suggestion ->here<-.
Hello, I’m Wei-ern_520, and I will randomly appear in your room! Just kidding, I make rpg engines.
I have no custom pfp, not because I don't know how to make one. I just don't know what suits me best, and I'm just too lazy and prefer sticking to simplicity. Or at least so. I also have the need to trip people with my profile picture. Just wait till it happens.
Fun fact: you don't clean your mess, you move it somewhere else. (Source: somewhere)
Also: Ooh, look at the cheese!
- Mr_PenguinAlex
- Scratcher
1000+ posts
have a sprite follow another sprite, like in RPGs
nohttps://scratch.mit.edu/projects/572796812/Is it scrolling?
I can't figure out how to make a sprite follow the player like in an RPG.
- Wei-ern_520
- Scratcher
500+ posts
have a sprite follow another sprite, like in RPGs
Then use this
In player:
Follower:
I think this should work.
Edit;fixed
In player:
when green flag clicked
forever
add (x position) to [x v]
add (y position) to [y v]
if <(length of [x v] :: list) > [1000]> then
delete [1] of [x v]
end
if <(length of [y v] :: list) > [1000]> then
delete [1] of [y v]
end
end
Follower:
when green flag clicked
forever
go to x: (item ((length of [x v])-(10)) of [x v]) y: (item((length of [y v])-(10))of [y v])
end
I think this should work.
Edit;fixed
Last edited by Wei-ern_520 (Sept. 21, 2021 01:25:21)
Please consider checking out my suggestion ->here<-.
Hello, I’m Wei-ern_520, and I will randomly appear in your room! Just kidding, I make rpg engines.
I have no custom pfp, not because I don't know how to make one. I just don't know what suits me best, and I'm just too lazy and prefer sticking to simplicity. Or at least so. I also have the need to trip people with my profile picture. Just wait till it happens.
Fun fact: you don't clean your mess, you move it somewhere else. (Source: somewhere)
Also: Ooh, look at the cheese!
- Just_Iakov
- Scratcher
100+ posts
have a sprite follow another sprite, like in RPGs
Then use this
In player:when green flag clicked
forever
add (x position) to [x v]
add (y position) to [y v]
if <(length of [x v] :: list) > [1000]> then
delete (length of [x v] :: list) of [x v]
end
if <(length of [y v] :: list) > [1000]> then
delete (length of [y v] :: list) of [y v]
end
end
Follower:when green flag clicked
forever
go to x: (item (10 (you can tweak these)) of [x v] :: list) y: (item(10 (you can tweak these))of [y v] :: list)
end
I think this should work.
This script won't work well.
delete (length of [x] :: list) of [list x]
We are removing all of the paths making it impossible for the other sprite to follow along.
delete (1) of [x]
Having just 1 is enough.
For follower.
The closer the item number is to the max value of the list, the faster it will follow it.
Although Wei-ern_520's script works none stop, means if you don't move at all, the follower would still go to the main sprite. This can create “glue effect”, where two sprites are very close to each other, and its pretty much impossible to get away from it.
I hope this clears up a few things.
Edit: An example project of the following system: https://turbowarp.org/572834566 it's a bit old, but it covers the needs of animation and just following a sprite along.
This script allowed me to create a 4 person following the path system: https://scratch.mit.edu/projects/562605195/
I hope these examples can come in helpful.
Last edited by Just_Iakov (Sept. 21, 2021 01:25:23)
My projects: A pen trail project || Omori Tag system || Undertale Soul modes || Pixel explosion || Undertale text system || Cloud Name Leaderboard || Planning to make more.
- Wei-ern_520
- Scratcher
500+ posts
have a sprite follow another sprite, like in RPGs
I have quite forgotten the code, so that’s why I messed up. Thanks for fixing it though. I’ll edit it too. -snip-
Last edited by Wei-ern_520 (Sept. 21, 2021 01:21:04)
Please consider checking out my suggestion ->here<-.
Hello, I’m Wei-ern_520, and I will randomly appear in your room! Just kidding, I make rpg engines.
I have no custom pfp, not because I don't know how to make one. I just don't know what suits me best, and I'm just too lazy and prefer sticking to simplicity. Or at least so. I also have the need to trip people with my profile picture. Just wait till it happens.
Fun fact: you don't clean your mess, you move it somewhere else. (Source: somewhere)
Also: Ooh, look at the cheese!
- Discussion Forums
- » Help with Scripts
- » have a sprite follow another sprite, like in RPGs