Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Finding the Position of a Clone
- scratchcoolbus
-
8 posts
Finding the Position of a Clone
I am trying to make a tower defense and i need to use the x and y position of a clone but i cant figure it out. Here is my code
But it is only using the sprite's x and y position, not any of the clone's
add (x position) to [list v]
add (y position) to [list v]
But it is only using the sprite's x and y position, not any of the clone's
Last edited by scratchcoolbus (Sept. 2, 2024 02:38:56)
- Jlerpy
-
1000+ posts
Finding the Position of a Clone
Have you got these inside the “when I start as a clone” section?
- bsteichman
-
500+ posts
Finding the Position of a Clone
you gotta have it inside the clone
one thing to note, is that if you're adding their positions onto the list constantly, the list will grow constantly, and the same values won't be updated.
wouldn't it make more sense to use the
so that if your clone has the id of 5, the 5th value will always be updated with the X?
create clone of [myself v]meanwhile:
add (x position) to [list v] //this is wrong
create clone of [myself v]
when I start as a clone
add (x position) to [list v] //this is correct
one thing to note, is that if you're adding their positions onto the list constantly, the list will grow constantly, and the same values won't be updated.
wouldn't it make more sense to use the
replace item ( v) of [list v] with [thing]block?
so that if your clone has the id of 5, the 5th value will always be updated with the X?
Last edited by bsteichman (Sept. 2, 2024 04:03:03)
- scratchcoolbus
-
8 posts
Finding the Position of a Clone
Thank you so much, ive been at it for such a long time
Edit: this for some reason is only taking the x and y of the original and not any of the clones
Edit: this for some reason is only taking the x and y of the original and not any of the clones
Last edited by scratchcoolbus (Sept. 2, 2024 22:28:04)
- TheNoisyNoisy
-
100+ posts
Finding the Position of a Clone
ok then, do Thank you so much, ive been at it for such a long time
Edit: this for some reason is only taking the x and y of the original and not any of the clones
when I start as a clone
forever
delete (all v) of [list v]
add (x position) to [list v]
add (y position) to [list v]
end
- Woodfur
-
100+ posts
Finding the Position of a Clone
Is the list itself “for all sprites”? Otherwise each clone will have a copy no other sprite can access.
- Jlerpy
-
1000+ posts
Finding the Position of a Clone
Yes, the list is all sprites, for exactly the reason you say. Otherwise you can't get the clones to report.
- deck26
-
1000+ posts
Finding the Position of a Clone
Bad idea - only one clone's data will ever be in the lists.ok then, do Thank you so much, ive been at it for such a long time
Edit: this for some reason is only taking the x and y of the original and not any of the cloneswhen I start as a clone
forever
delete (all v) of [list v]
add (x position) to [list v]
add (y position) to [list v]
end
- deck26
-
1000+ posts
Finding the Position of a Clone
I think you need to share the project so we can see what you're doing.
- TheNoisyNoisy
-
100+ posts
Finding the Position of a Clone
oops use ids thenBad idea - only one clone's data will ever be in the lists.ok then, do Thank you so much, ive been at it for such a long time
Edit: this for some reason is only taking the x and y of the original and not any of the cloneswhen I start as a clone
forever
delete (all v) of [list v]
add (x position) to [list v]
add (y position) to [list v]
end
- scratchcoolbus
-
8 posts
Finding the Position of a Clone
Yo I cant thank yall enough This time it worked for real
if <chat helpful> then
say [Thank you]
end
- scratchcoolbus
-
8 posts
Finding the Position of a Clone
Sadly i have another problem
i need to find the nearest clone's distance to another clone but its taking the original sprite and not the nearest clone any help?
I Need to use this block:
i need to find the nearest clone's distance to another clone but its taking the original sprite and not the nearest clone any help?
I Need to use this block:
(distance to [ v Nearest Enemy Clone])
Last edited by scratchcoolbus (Sept. 15, 2024 21:25:42)
- codeywhizz
-
100+ posts
Finding the Position of a Clone
yea ur gonna need some algorithmic thinking for that, literally the best way is to brute force through every combination of 2 clones Sadly i have another problem
i need to find the nearest clone's distance to another clone but its taking the original sprite and not the nearest clone any help?
I Need to use this block:(distance to [ v Nearest Enemy Clone])
- TheNoisyNoisy
-
100+ posts
Finding the Position of a Clone
why would you NEED to use that block? Sadly i have another problem
i need to find the nearest clone's distance to another clone but its taking the original sprite and not the nearest clone any help?
I Need to use this block:(distance to [ v Nearest Enemy Clone])
- scratchcoolbus
-
8 posts
Finding the Position of a Clone
I found an equation using that block that makes my projectile arc but i cant with any other block. this is the equation:
Unless any of you know a work around
repeat (41)
change x by ((round (distance to [Enemy Clone])) / (41))
change y by (Y Velocity)
end
Unless any of you know a work around
Last edited by scratchcoolbus (Sept. 16, 2024 18:56:52)
- Discussion Forums
- » Help with Scripts
-
» Finding the Position of a Clone