Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » MORE CLONES HELP!!!
- MaxMax4U2
- Scratcher
9 posts
MORE CLONES HELP!!!
How do I make a sprite go to the closest clone of another sprite?
if only:
if only:
point in direction (([ closest clone] of [Humans v]))
- Cool_Dude2022
- Scratcher
100+ posts
MORE CLONES HELP!!!
How do I make a sprite go to the closest clone of another sprite?
if only:point in direction (([ closest clone] of [Humans v]))
I made a project that has exactly what you might need.
(https://scratch.mit.edu/projects/964418154/)
Did I help you fix your problem? If so, please nominate my project to be featured!
If my code is used, credit is NOT required
- MaxMax4U2
- Scratcher
9 posts
MORE CLONES HELP!!!
thanks but… its missing something
How do I make a sprite go to the closest clone of another sprite?
if only:point in direction (([ closest clone] of [Humans v]))
I made a project that has exactly what you might need.
(https://scratch.mit.edu/projects/964418154/)
- invalidaccess
- Scratcher
100+ posts
MORE CLONES HELP!!!
i think you need list for that.just add every single clones position in list and let the other clone to check the closest one(with some math of course)
- MaxMax4U2
- Scratcher
9 posts
MORE CLONES HELP!!!
example? (sorry) i think you need list for that.just add every single clones position in list and let the other clone to check the closest one(with some math of course)
- WhyteTIGER
- Scratcher
16 posts
MORE CLONES HELP!!!
You need to make 2 lists (1 with x and 2nd with y positions) and then calculate the distance to the clone.
Formula for distance:
d = sqrt((x2 - x1)^2 + (y2 - y1)^2)
Once you find the closest one you have to make it point towards the clone which is hard because the formula is long. But I have a way around it: Make another sprite and call it “pointer” or something like that and when the closest clone is found then it goes to it and then you can easily make your sprite point towards the “pointer”
Formula for distance:
d = sqrt((x2 - x1)^2 + (y2 - y1)^2)
Once you find the closest one you have to make it point towards the clone which is hard because the formula is long. But I have a way around it: Make another sprite and call it “pointer” or something like that and when the closest clone is found then it goes to it and then you can easily make your sprite point towards the “pointer”
say [I hope this helped you!] for (2) secs
Hey there!
I've been active on scratch for almost 5 years on different accounts. I enjoy creating, coding and sharing good quality projects and helping others with their code
My top 3 best projects:
1. HYPERCAR RACING
2. CUBLOX
3. FLAPPY BIRD - Mobile Friendly Remake
- Discussion Forums
- » Help with Scripts
- » MORE CLONES HELP!!!