Discuss Scratch

St19_Chuba
Scratcher
99 posts

Individual Variables For Each Clone?

As the title says, i need variables on clones to be seperate, kinda like directions.

I'm using velocity for a ricochet on a projectile, but it affects all clones ;-;

Say a clone changes it's x velocity by 1. Every clone then does the same, but i dont want that D:<

Any way to fix this? I would really appreciate it if someone told me
awesome-llama
Scratcher
1000+ posts

Individual Variables For Each Clone?

Use local variables. When it is cloned, the variable stays with the clone as an independent variable. This is useful to do many things like velocity or health.
crisostimo
Scratcher
500+ posts

Individual Variables For Each Clone?

I have a well commented tutorial on cloning sprites that may help you:

https://scratch.mit.edu/projects/94046493/
Studio42
Scratcher
500+ posts

Individual Variables For Each Clone?

“For this sprite only” variables also mean “For this clone only”
footsocktoe
Scratcher
1000+ posts

Individual Variables For Each Clone?

St19_Chuba wrote:

As the title says, i need variables on clones to be seperate, kinda like directions.

I'm using velocity for a ricochet on a projectile, but it affects all clones ;-;

Say a clone changes it's x velocity by 1. Every clone then does the same, but i dont want that D:<

Any way to fix this? I would really appreciate it if someone told me

You have to use a clone ID system if you want individual clones to have different behaviors from other clones.
harryssk14
Scratcher
1 post

Individual Variables For Each Clone?

All cones have same health
deck26
Scratcher
1000+ posts

Individual Variables For Each Clone?

harryssk14 wrote:

All cones have same health
Not if you use local variables as described and each clone manages its own variable. Please don't post on old topics - if you need help create a new topic, describe the issue and. preferably, share the project.
geramihasfood
Scratcher
100+ posts

Individual Variables For Each Clone?

St19_Chuba wrote:

As the title says, i need variables on clones to be seperate, kinda like directions.

I'm using velocity for a ricochet on a projectile, but it affects all clones ;-;

Say a clone changes it's x velocity by 1. Every clone then does the same, but i dont want that D:<

Any way to fix this? I would really appreciate it if someone told me
You need to use local variables. To do that, when creating a variable you need to click For this sprite only instead of the For all sprites. This sets it to a local variable, meaning a variable that only the sprite and its' clones can access it.

That also means that clones can create a copy of that variable and so when you change the variable in the clone, it won't change the variables in other clones.

Edit: I didn't look at the date. ;-;

Last edited by geramihasfood (March 26, 2025 15:37:44)

Powered by DjangoBB