Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Help With Clones
- CadeVegas13
-
Scratcher
51 posts
Help With Clones
How the heck do I make multiple clones each go in a different direction?
- medians
-
Scratcher
1000+ posts
Help With Clones
Each clone has a different direction, so if you use this code:

You get this:


You get this:

- CadeVegas13
-
Scratcher
51 posts
Help With Clones
No, I'm trying to make each clone go in a specific direction. In specific, I'm trying to make 5 clones (which are projectiles) that each go in a shotgun spread.
- deck26
-
Scratcher
1000+ posts
Help With Clones
So use a loop to create 5 clones, changing the direction for each one. If you don't want to change the direction of the object that is doing the cloning use a separate variable and set the direction to that variable in the clone's script.
- CadeVegas13
-
Scratcher
51 posts
Help With Clones
So like this?
when I receive [...]
repeat (5)
create clone of [bullet]
end
when I start as a clone
repeat until <whatever>
point in direction (random variable)
move (10) steps
end
delete this clone
Or something else?
Last edited by CadeVegas13 (April 6, 2023 17:03:58)
- frozenraccoon
-
Scratcher
7 posts
Help With Clones
If want to use a specific direction, the variable you are setting must be limited to that sprite only. then go to the clone making script and insert the variable. to set each clone a different you will need another variable called that change whenever a clone is created. in the end it should look something like this.
when green flag clickedif you want something more specific you'll need lists which i don't much about but i hope this helps nonetheless
forever
set [Sprite1:cloneDirection v] to ((15) * (cloneNumber))
change [cloneNumber v] by (1)
create clone of [Sprite1 v]
end
when I start as a clone
turn cw (Sprite1:cloneDirection) degrees
Last edited by frozenraccoon (April 6, 2023 17:20:30)
- CadeVegas13
-
Scratcher
51 posts
Help With Clones
Thanks, but I need the spread of bullets to be in the same direction as the player.
- frozenraccoon
-
Scratcher
7 posts
Help With Clones
well thats an easy fix just add a line of code telling go to the player, make a variable that tell what direction its facing. example:
when green flag clickedif you making a sort of top down gamer where player is facing the mouse pointer, you can just use
hide
go to [Player v]
point in direction (playerDirection)
when green flag clicked
forever
set [Projectile1:cloneDirection v] to ((15) * (cloneNumber))
change [cloneNumber v] by (1)
create clone of [Projectile v]
end
when I start as a clone
turn cw (Projectile1:cloneDirection) degrees
point towards [mousepointer v]
Last edited by frozenraccoon (April 6, 2023 17:29:09)
- frozenraccoon
-
Scratcher
7 posts
Help With Clones
i used this exact for one my games when i was making a shotgun, so it will definitely work for you! just make sure to add a code in your player to set the variable to were there facing.
Last edited by frozenraccoon (April 6, 2023 17:29:45)
- CadeVegas13
-
Scratcher
51 posts
Help With Clones
AGH IT JUST MAKES THE BULLETS GO IN A SPIRAL AROUND ME
- CadeVegas13
-
Scratcher
51 posts
Help With Clones
Can you put the link to your game that you used it in?
- CadeVegas13
-
Scratcher
51 posts
Help With Clones
Actually just remix this: https://scratch.mit.edu/projects/784602394/editor/ and edit the code. (BTW there are 2 weapons; a pistol and a shotgun).
- austinjeffrybatman
-
Scratcher
25 posts
Help With Clones
AGH IT JUST MAKES THE BULLETS GO IN A SPIRAL AROUND MEReplace the 15 with a 1 or 2.
- CadeVegas13
-
Scratcher
51 posts
Help With Clones
KUMQUAT DEFENDER
Last edited by CadeVegas13 (April 6, 2023 20:38:47)
- medians
-
Scratcher
1000+ posts
Help With Clones
No, I'm trying to make each clone go in a specific direction. In specific, I'm trying to make 5 clones (which are projectiles) that each go in a shotgun spread.Yeah, I was providing an example of the direction thing I was talking about.
Nvm about the clone thing, frozenraccoon helped meOkay, do you have any more questions?
- Discussion Forums
- » Help with Scripts
-
» Help With Clones




Thanks!
