Hello, I am creating a Slither.io style game, but I have a collision problem between the enemies.
I have two objects, both with variable ID, which is stored the value "Head.UID".
I want to check if the "Head" object collided with the "Body" object, but only destroy the "Head" object if the variable "Head.ID" is different from the variable "Body.ID"
That is, destroy the "Head" object when it collides with another enemy's body. Thus, the Head object is destructive as soon as a Body is created on top of the Head. I will leave the project and an image to be easier to understand.
Sorry for the horrible english
Your code is almost right, but you're missing a "For Each Head" loop after the "Every 0.05 seconds" that will tell exactly what ID is each body.
Right now you're picking all the bodies which are overlapping A head (but you don't know which one exactly), and you tell them to take the same ID as this head but it's very confusing and only one of the three bodies actually have the good ID in the end.
If you add a For Each loop somewhere, every head will spawn a Body and the body knows it must take this same head's UID.
Here is the working file :)
Develop games in your browser. Powerful, performant & highly capable.
Thank you very much Semoreh
It worked perfectly, thank you very much you helped me a lot.