- Home /
Question by
dragonero94 · Apr 15, 2020 at 08:31 AM ·
collsion
Is possible detect collision on gameobject created in an empty gameobject?
Hello, I have an empty gameobject and a script attached to it in which I create some boxes with the function CreatePrimitive to create a membrane with multiple boxes. The boxes are NOT a child of the empty gameobject. I need a way to detect a collision on one of these boxes in the same previous script. Thank you
Comment
Answer by dragonero94 · Apr 15, 2020 at 09:54 PM
I think i resolve by myself. For who is interesting: create a variable bool in the main script (where is the CreatePrimitive) and attach to the boxes created another script where you change the same bool variable in true or false in OnCollisionStay and OnCollisionExit respectively. With GetComponent in the main script, you can read if the bool variable is true or false.