How do you control a clone without effecting the original (cloned) object?

code
help
clones
helpwithcode

#1

When you use the block-

Create A Clone of this Character

- the clone itself doesn't become a new, separate character, and any subsequent code blocks still control the original character and not the clone. So I'm wondering if it is possible to apply code to just the clone and not the original?


#2

Use the' when Character is cloned block'


#3

Welcome to the forum! What you need to do is put the code controlling the clone in a new rule. The rule should have "when the character is cloned". And if that's you in your profile picture, please change it, as we can't share personal info like that here.


#4

Welcome to the forum! Tag me like "@KVJ" anytime you need help!

Yeah like they said just use When Character is Clones :wink:


#5

U can also tag me as @TheRealBlah


#6

hello! i guess you made an account to get help?
use the "when character is cloned" action. that will make only the CLONES move, not the main character.


#7

Welcome to the wonderful Hopscotch forum!

Just tap "add a new when", and then find the block that says "object is cloned", and you can put the object's code in there! :D


#8

@Metaforest Are you asking how to control a clone without affecting the original:

at the time that the clone is created?
or
during subsequent events?

The former was explained above. The later requires some trickery using a pseudo-index property.

If you were asking how to control a clone during subsequent events without affecting the original, just let us know and I'm sure one of the very helpful individuals on the forum will expand the explanation.


#9

This is a very broad and difficult topic, and one I have spent many hours on.
As people have mentioned above, when you want just clones to do one thing, you simply create a new "When clone is created" rule, and put the action you want the clone to do in there.

However, if you want to detect when a certain clone touches something, or have a clone act when something happens (ie, in a different rule), it gets more complicated. Let us take the example, we want to find when a clone of a circle hits a line object.
The general rule you have to remember is that there are some variables that are clone specific. These variables are x position, y position, speed, invisibility, and size. All of these vary per clone, and you can use this to set clone-dependant variables. So, have a rule that says "When circle bumps line". Now this will trigger for all clones when any one clone touches the line, so you have to say "When circle bumps line, check if my x position and my y position is close to that of the line.
To do this in Hopscotch, simply remember the distance formula: Sqrt( (lx-cx)^2+(ly-cx)^2 ) where lx is the line x position, cs is the circle x position.

So our final rule:

When Circle bumps Line
Check once if Sqrt( (lx-cx)^2+(ly-cx)^2 )<20
      (do something)

This will make only the circle that bumped the line do whatever is past the check once if.

If you say, want only 10 of 100 clones to touch that line, then in the 'when clone is created' tab, if the clone is the tenth or less clone (can you figure out how to make that with values?), set it's speed to 300 or any arbitrary integer. Then, in your when circle bumps line rule, add another check once if that evelopes the first one: Check once if speed = 300 (or whatever number you put)

I know these examples were very specific but hopefully they gave you an idea of how to use clone-dependant variables in general. Sorry if this didn't make any sense or was overcomplicated - it's a very messy method that we still haven't really perfected.

As of now, we still don't know how to make clones interact with other clones - as it stands, I don't believe it to be possible.