So I’ve been trying to use the hitInfo inside some OnCollisionEnter function and I want to take advantage of the tag the gameObject has:
void OnCollisionEnter (Collision hitInfo) {
if (hitInfo.gameObject.tag == "Pad") {
Debug.Log("Pad HIT! " + hitInfo.gameObject.name);
}
}
This won’t work! The gameObject tagged as “Pad” has lots of child objects that remain untagged. However if I try this with having the top child object tagged it works. From my understanding what is happening is that when the collision with the Pad happens Unity doesn’t see it as a collision with the whole Pad object but with one of its untagged children. Now that’s a problem because I do not want to start tagging the children I just want to have the whole parent object tagged since that’s what the rest of the environment has to interact with. How do I solve this?
EDIT: This also messes up when I try to use gameObject.name since it won’t recognize the gameObject. It gives me a NullReferenceException
Avec du retard je veux bien te remercier avec plaisir... Merci merci merci :) c'est cool de se préoccuper des autres, mais personnellement je ne m'attends pas à une mise en avant sur mes aides même si je ne fais aucunes encort sur unity... php js as et autres langages ne m'ont pas nourris sur la satisfaction personnel dans les échanges... enjoy body
– LiovaLou