Discuss Scratch
- Discussion Forums
- » Suggestions
- » Clones of a sprite being able to detect distance to clones of another sprite.
- mmnnbbvvccxx987
-
Scratcher
7 posts
Clones of a sprite being able to detect distance to clones of another sprite.
A very helpful improvement for me would be to add a block that can allow clones of one sprite to detect distance to clones of another sprite. This would make it much easier to make tower defense/strategy games as currently there is not a viable way for clones to detect distance to other clones. They can only detect when they touch. A block like (distance from clone of sprite A). I have been unable to finish many games I tried to make because of this issue.
- PhiPhenomenon
-
Scratcher
500+ posts
Clones of a sprite being able to detect distance to clones of another sprite.
This block would be helpful in this situation, but it seems too niche to be useful. Scratch should have blocks that can be used in a lot of situations, so this seems a bit too specific.
There are also a few ambiguities that need to be figured out. What happens when there are multiple clones touching it? Does it report the closest one? What happens if there are no clones touching it?
Anyway, there is a viable way of detecting clones, but it's not immediately obvious.
There are also a few ambiguities that need to be figured out. What happens when there are multiple clones touching it? Does it report the closest one? What happens if there are no clones touching it?
Anyway, there is a viable way of detecting clones, but it's not immediately obvious.
- mmnnbbvvccxx987
-
Scratcher
7 posts
Clones of a sprite being able to detect distance to clones of another sprite.
Not a block for detecting if a clone is touching clones, as there is a viable way to do that, a block for a clone to detect the DISTANCE to the nearest clone. This could have a number of uses, such as the clone moves away if a clone is near it, moves towards the nearest clone, changes its costume if a clone gets near it, broadcast a message if a clone gets near it.
It's true that it would only be helpful with games that have multiple types of clones, but they already make it so the clones can detect when they touch another clone, so it feels like it makes sense that they could sense distance also.
With the ambiguities, if there are multiple clones the same distance it would react the same way a sprite would if 2 other sprites were an equal distance apart. Also, this block would have nothing to do with if it was touching a sprite or not, as that can already be detected. It only focuses on the distance to the nearest clone of a sprite. If the clone is already on the clone, the distance would read zero.
Sprites can't detect the distance to a clone but it can still be accomplished by having the clone broadcast a message when its near the sprite, as clones can detect distance to a sprite, however since nothing can detect the distance to a clone, it ends a lot of possibilities. There is no viable way of making clones detect distance to other clones either, without using 500+ blocks and even then, you can't use it in most situations.
It's true that it would only be helpful with games that have multiple types of clones, but they already make it so the clones can detect when they touch another clone, so it feels like it makes sense that they could sense distance also.
With the ambiguities, if there are multiple clones the same distance it would react the same way a sprite would if 2 other sprites were an equal distance apart. Also, this block would have nothing to do with if it was touching a sprite or not, as that can already be detected. It only focuses on the distance to the nearest clone of a sprite. If the clone is already on the clone, the distance would read zero.
Sprites can't detect the distance to a clone but it can still be accomplished by having the clone broadcast a message when its near the sprite, as clones can detect distance to a sprite, however since nothing can detect the distance to a clone, it ends a lot of possibilities. There is no viable way of making clones detect distance to other clones either, without using 500+ blocks and even then, you can't use it in most situations.
- PhiPhenomenon
-
Scratcher
500+ posts
Clones of a sprite being able to detect distance to clones of another sprite.
Not a block for detecting if a clone is touching clones, as there is a viable way to do that, a block for a clone to detect the DISTANCE to the nearest clone.I am aware of that, but your block does rely on the touching function.
This could have a number of uses, such as the clone moves away if a clone is near it, moves towards the nearest clone, changes its costume if a clone gets near it, broadcast a message if a clone gets near it.All of these uses are niches within a niche, meaning that they're even rarer than the block itself being used. This block would only apply to the nearest clone, so what happens when two clones are inside of a specific range? Only the clone closest to the clone used to detect distances would be affected.
It's true that it would only be helpful with games that have multiple types of clones, but they already make it so the clones can detect when they touch another clone, so it feels like it makes sense that they could sense distance also.That's because they essentially act the same way as sprites, as an “extension” of sorts. Clones inherit attributes from their parent sprite, so detecting touch is pretty easy, but I'd assume that their positions would become different, so distance is much trickier.
With the ambiguities, if there are multiple clones the same distance it would react the same way a sprite would if 2 other sprites were an equal distance apart.A sprite can't react that way because you can't have two sprites with the same name to detect. I assume you mean that it would simply report the closest one.
Also, this block would have nothing to do with if it was touching a sprite or not, as that can already be detected. It only focuses on the distance to the nearest clone of a sprite. If the clone is already on the clone, the distance would read zero.You said this in the Original Post:
This would make it much easier to make tower defense/strategy games as currently there is not a viable way for clones to detect distance to other clones. They can only detect when they touch.Should I only consider the most recent changes? You have to be more clear.
Anyway, the way you described this still has an issue.

You say, “If the clone is already on the clone, the distance would read zero.” First of all, I thought this block would have nothing to do with if it was touching a sprite or not. Also, Scratch measures distance by computing the distance between the sprite centers, not their edges (that'd be too resource intense). It'd be better to keep it consistent with how it's measured in the rest of the editor.
Sprites can't detect the distance to a clone but it can still be accomplished by having the clone broadcast a message when its near the sprite, as clones can detect distance to a sprite, however since nothing can detect the distance to a clone, it ends a lot of possibilities. There is no viable way of making clones detect distance to other clones either, without using 500+ blocks and even then, you can't use it in most situations.That may be true, but it still stands that Scratch should not produce a block to solve every tiny problem. An even more common block suggested was a platformer physics block, but that was never implemmented, though it could have saved hundreds of blocks! Everything in Scratch should be baseline and able to apply to lots of things. Maybe next time if you need help creating this script, you should create a topic in HwS.
- mmnnbbvvccxx987
-
Scratcher
7 posts
Clones of a sprite being able to detect distance to clones of another sprite.
It has nothing to do with clones touching other clones. Its only a suggestion for some type of block that can monitor the distance to the nearest clone. If the block existed then it could theoretically be used to also detect if a clone was touching a clone as you would use: IF distance to nearest clone < (and here you would input however much distance it takes for the clones to touch) THEN: do something else. I am only suggesting a
“distance to nearest clone” block or maybe even just a “distance to nearest clone” option in the “distance to ____” block. Like this block:
It has options for distance to mouse pointer, and then any sprite. I am suggesting there is an option for a “nearest clone” distance here.
With that diagram you made with the circles, it would obviously to it consistent to how its usually measured.
CURRENTLY in scratch there is a way to detect when a clone is touching a sprite, or when a clone is touching a clone, however there is CURRENTLY no viable way to detect the distance between 2 clones in scratch.
I am SUGGESTING that they add a way to detect this.
“distance to nearest clone” block or maybe even just a “distance to nearest clone” option in the “distance to ____” block. Like this block:
It has options for distance to mouse pointer, and then any sprite. I am suggesting there is an option for a “nearest clone” distance here.
With that diagram you made with the circles, it would obviously to it consistent to how its usually measured.
CURRENTLY in scratch there is a way to detect when a clone is touching a sprite, or when a clone is touching a clone, however there is CURRENTLY no viable way to detect the distance between 2 clones in scratch.
I am SUGGESTING that they add a way to detect this.
Last edited by mmnnbbvvccxx987 (Oct. 5, 2023 21:22:11)
- mmnnbbvvccxx987
-
Scratcher
7 posts
Clones of a sprite being able to detect distance to clones of another sprite.
This is what was supposed to be after when I put: When I said Like this block:
(distance to [ v])
- mmnnbbvvccxx987
-
Scratcher
7 posts
Clones of a sprite being able to detect distance to clones of another sprite.
So what I'm trying to say is, they might not even have to add an entirely new block and it may not be such a hard thing for them to implement, and I think it could be relatively helpful to coders on scratch.
- IndexErrorException
-
Scratcher
500+ posts
Clones of a sprite being able to detect distance to clones of another sprite.
There are ways to do this, and you would not want to have a advanced tower based game using clones, much rather a pure pen stamping based system,
with about as much control as you need.
with about as much control as you need.
- Discussion Forums
- » Suggestions
-
» Clones of a sprite being able to detect distance to clones of another sprite.