Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Clones And Broadcasts
- -Mako_Shark-
-
Scratcher
10 posts
Clones And Broadcasts
I'm making something with multiple sprites where if one sprite “hurts” another, it broadcasts a message to it. However, the entity it's hurting is actually a clone. Since the hat and the hat are both… well, hats, I can't join them together unless I use some variable that changes when the message is broadcasted (which is really ugly). Is there a way around this, or should I just not use broadcasts at all?
- mstone326
-
Scratcher
1000+ posts
Clones And Broadcasts
Have you used the WHen I start as Clone block in the control category? The clones can follow those instructions.
Otherwise, you'll have to broadcast and use some type of condition so that only the clone that needs to respond responds. If you can share your project we can offer more specific advice.
Otherwise, you'll have to broadcast and use some type of condition so that only the clone that needs to respond responds. If you can share your project we can offer more specific advice.
- randomsketchartist
-
New Scratcher
57 posts
Clones And Broadcasts
I came up with two ideas:
The first one, use a variable, then change its value when it ‘hurts’ another sprite, then in the clone's code, do an if loop, and if the variable is at a certain value, do whatever you wanted to do.
The second one, instead of sending a message with the sprite that's ‘hurting’ the other one, make the ‘hurt’ clone broadcast it.
I don't think I explained it very well and I'm not sure if it works because I'm too much into animating to code a test project(my name says so already lol).
The first one, use a variable, then change its value when it ‘hurts’ another sprite, then in the clone's code, do an if loop, and if the variable is at a certain value, do whatever you wanted to do.
The second one, instead of sending a message with the sprite that's ‘hurting’ the other one, make the ‘hurt’ clone broadcast it.
I don't think I explained it very well and I'm not sure if it works because I'm too much into animating to code a test project(my name says so already lol).
Last edited by randomsketchartist (Jan. 3, 2021 21:54:39)
- -Mako_Shark-
-
Scratcher
10 posts
Clones And Broadcasts
Have you used the WHen I start as Clone block in the control category? The clones can follow those instructions.Oops something in my post did not show up haha
Otherwise, you'll have to broadcast and use some type of condition so that only the clone that needs to respond responds. If you can share your project we can offer more specific advice.
What I meant was, the When I Start As Clone hat and the When I Receive Message hat are both hats, you can't link them together.
- mstone326
-
Scratcher
1000+ posts
Clones And Broadcasts
Correct. Here is an example I made the other day for someone broadcast to a clone. Not sure if this helps, but notice my when i receive block, has an if touching condition. That way only a clone that tests True will respond. Sharing your project will help us help you.
https://scratch.mit.edu/projects/469006443/
https://scratch.mit.edu/projects/469006443/
- -Mako_Shark-
-
Scratcher
10 posts
Clones And Broadcasts
I came up with two ideas:Yeah I was considering the first one, but I think it's too messy and maybe unnecessary?
The first one, use a variable, then change its value when it ‘hurts’ another sprite, then in the clone's code, do an if loop, and if the variable is at a certain value, do whatever you wanted to do.
The second one, instead of sending a message with the sprite that's ‘hurting’ the other one, make the ‘hurt’ clone broadcast it.
I don't think I explained it very well and I'm not sure if it works because I'm too much into animating to code a test project(my name says so already lol).
I don't think your second idea will work, since it has to be specific to the clone itself. I would have to create a new broadcast message for each clone, and that's even messier than the first

- -Mako_Shark-
-
Scratcher
10 posts
Clones And Broadcasts
Correct. Here is an example I made the other day for someone broadcast to a clone. Not sure if this helps, but notice my when i receive block, has an if touching condition. That way only a clone that tests True will respond. Sharing your project will help us help you.Ye I get the if touching part, but I'd prefer a broadcast, because if touching can touch two at once and stuff like that.
https://scratch.mit.edu/projects/469006443/
Also, to be honest, I have barely made the project yet, but I was kinda thinking ahead.
- mstone326
-
Scratcher
1000+ posts
Clones And Broadcasts
Not necessarily but without seeing the project all I can do is offer guesses.
- -Mako_Shark-
-
Scratcher
10 posts
Clones And Broadcasts
Not necessarily but without seeing the project all I can do is offer guesses.I can give an example though:
For shooter games or something (that's not what I'm making but whatever), multiple “bullets” are fired in quick succession. Spawning a clone for all of these bullets really becomes unnecessary because of the speed they travel at, making the target get hit instantly as you point at it. My idea is like, when you point at a target, it keeps broadcasting a message (named Pointing At). Every clone then takes in this broadcast to see if they are being “fired” at, even though nothing is actually hitting them.
I could use a lot of “bullets”, but to cut down on lag I think the broadcast-clone idea is more useful.
- randomsketchartist
-
New Scratcher
57 posts
Clones And Broadcasts
hmm… I don't really get what you're saying here, your two examples are a little different in my opinionNot necessarily but without seeing the project all I can do is offer guesses.I can give an example though:
For shooter games or something (that's not what I'm making but whatever), multiple “bullets” are fired in quick succession. Spawning a clone for all of these bullets really becomes unnecessary because of the speed they travel at, making the target get hit instantly as you point at it. My idea is like, when you point at a target, it keeps broadcasting a message (named Pointing At). Every clone then takes in this broadcast to see if they are being “fired” at, even though nothing is actually hitting them.
I could use a lot of “bullets”, but to cut down on lag I think the broadcast-clone idea is more useful.
- Discussion Forums
- » Help with Scripts
-
» Clones And Broadcasts