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
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
- set a flag (aka a boolean variable) to
false
- for each clone in the object, check if
this
is touching the clone (withhitTest
) - if
this
is touching the clone, set the aforementioned flag totrue
. - 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. - 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.
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.
yeah it worked