Discuss Scratch

Happy_AlexRO
Scratcher
7 posts

Distance to clone

I started making a new FNF input in my fnf test on Scratch but It seems that clones didn't detect the (distance to {thing}) block.

In the danger sprite, i put this script:
when green flag clicked
go to x: (0) y: (180)
Note that this sprite is visible!

But this is where the broken stuff shows up
The arrow sprite has these:
when I start as a clone
forever
change y by (10)
end

when I start as a clone
show
forever
if <(distance to [Danger v]) = [1]> then
broadcast [Miss! v]
delete this clone
end
end

Apparently, using this script, if touching the sprite Danger, doesn't delete anything. I tried putting the costume in the center of paint and put it up but nothing. I even grew up the (distance to (Danger)) operator value and nothing!

I even tried to see what's wrong and put
say (distance to [Danger v]) for (0.1) secs
in the “When I start as a clone” but it said the distance was 206.16 and it was touching the sprite Danger.

Can you guys help me?

Last edited by Happy_AlexRO (July 17, 2021 19:05:54)

IMattZiggy101
Scratcher
38 posts

Distance to clone

I feel like this is unnecessarily complicated. Can't you just check if the clone touched the Danger sprite? Also, you should just share your project and post the link here. It's easier than trying to write the blocks in.


https://scratch.mit.edu/discuss/topic/125196/?page=1#post-1114422
^ I found this old forum post about detecting clone distance if you still want to know how. ^

Last edited by IMattZiggy101 (July 17, 2021 19:22:16)

Happy_AlexRO
Scratcher
7 posts

Distance to clone

IMattZiggy101 wrote:

I feel like this is unnecessarily complicated. Can't you just check if the clone touched the Danger sprite? Also, you should just share your project and post the link here. It's easier than trying to write the blocks in.


https://scratch.mit.edu/discuss/topic/125196/?page=1#post-1114422
^ I found this old forum post about detecting clone distance if you still want to know how. ^
I also need it to rate the distance between the gray arrow and the colored one

Example: If the distance is small, broadcast “Sick!”
But if its big, broadcast “bad!”

That's why i need the distance block

Last edited by Happy_AlexRO (July 17, 2021 19:28:07)

BatteRaquette58
Scratcher
100+ posts

Distance to clone

You can do that:
Create a variable named “clone count” and put it for all sprites.
Create a variable named “clone number” and put it for only this sprite.
when green flag clicked
go to x: (0) y: (180)
set [clone count v] to [0]
delete all of [positions v]:: list
when I start as a clone
show
change [clone count v] by [1]
set [clone number v] to (clone count)
forever
change y by (10)
replace item (clone number) of [positions v] with (y position)
if <(distance to (Danger v)) = [1]> then
broadcast [Miss! v]
delete element (clone number) of [positions v]:: list
delete this clone
end
end

when I receive [user looking at my signature v]
intro
define intro
Heya!
I'm BatteRaquette58's siggy (insert sherlock icon)! I am here to help you with scripts! So if you have questions, ask them!
Art for pride month:
define . () () () () () () ()()()()
. (.)(.)(.)(.)(.)(.)(.)(.)(.)(.):: list
. (.:: events)(.:: events)(.:: events)(.:: events)(.:: events)(.:: events)(.:: events)(.:: events)(.:: events)(.:: events):: events
. (.:: operators)(.:: operators)(.:: operators)(.:: operators)(.:: operators)(.:: operators)(.:: operators)(.:: operators)(.:: operators)(.:: operators):: operators
. (.:: variables)(.:: variables)(.:: variables)(.:: variables)(.:: variables)(.:: variables)(.:: variables)(.:: variables)(.:: variables)(.:: variables):: variables
.(.:: motion)(.:: motion)(.:: motion)(.:: motion)(.:: motion)(.:: motion)(.:: motion)(.:: motion)(.:: motion)(.:: motion):: motion
.()()()()()()()()()()
pride flag:: cap
orangetheory
Scratcher
500+ posts

Distance to clone

As for the rating of distance, do this:

forever
if <(distance to [sprite you want v]) > (distance to [sprite you want v])> then
...::sensing // this place is for the "sick" or "bad" you choose
else
...::pen // if the original if statement above was "bad" then this section would be good, and vice versa.
end
end

Hope this helped

-Frisbee- -Cricket--Basketball--Forums--Mapping--Coding--Trigonometry master--Mathematics King--Future Prime Minister--Intro-Maker-
I know HTML/CSS, and JavaScript, and with these coding skills I have made some decent projects! Test them out below!
~Archery~Cops + Robbers~
Want an intro, outro, music, effects, or more? Check out the intro shop!

The forum helpers, a place where we help people in the forums
MasterofTheBrick
Scratcher
1000+ posts

Distance to clone

Like the second post, I feel that the distance block isn't needed. All you have to do is wait until the y position of the clone is greater than 180 (meaning that it missed because it passed the danger sprite without touching), and subtract the x position of the clone from 0, giving you the distance between the arrow and the danger sprite.

If you still don't understand any of the posts, maybe you should link the project for others to help you better.

Powered by DjangoBB