How to check if an object touches a clone of itself

im making a game and I need an object to see if it hits one of its clones

clones are stored in the array (object).clones where object is the name of the clip the clones are generated from
You just have to cycle check if your object hits a member of that array

2 Likes

how do I use this though?

im making a tron game and I followed what you said and it did nothing. My Project5-15-2023_11-08-16.wick

i think that every original object has a list of thier clones… you could use that

OriginalClipName.clones

tats the same thing @blurredPixels said, I need to know how to use it

  1. set a flag (aka a boolean variable) to false
  2. for each clone in the object, check if this is touching the clone (with hitTest)
  3. if this is touching the clone, set the aforementioned flag to true.
  4. optionally, you can exit the loop with a break statement after a collision was found, as nothing afterwards can change the flag to a different value, making continuing the loop a waste of time.
  5. now, this flag (boolean variable) determines if this is touching a clone of another object.

i’m not sure how proficient you are with programming, but i assume it’s hopefully enough for you to figure out how to write this.

you can use

for (let clone of object.clones) {
  // put code here
}

to go through each clone of an object. the clone currently being processed is in the clone variable inside the loop.

2 Likes

ok, this kind of helps but its also (from my knowledge, which isn’t that much) the same as what I have been trying to do.
if you know what to do (which I don’t) then here is the wick file for you to try and fix My Project5-17-2023_8-06-51.wick

Alright… here…

clonesHit5-17-2023_17-53-24.wick (2.2 KB)

In this example if they hits themselves, they turn green, else they stay yellow:

This is the part that does the trick, the rest of the code is just for the clones to move themselves.

@gamer_boi did this work for you?

yeah it worked