Is it even possible to check if a child gameobject of a parent object collided with lets say a terrain with tag “Terrain”?
I need to have the script on the parent object and just check if a child gameobject hit something.
Is it even possible to check if a child gameobject of a parent object collided with lets say a terrain with tag “Terrain”?
I need to have the script on the parent object and just check if a child gameobject hit something.
I think you need to do it in the other way around,
You have a script attached to the child object, with the function OnCollisionEnter2D.
And when this get triggered, your child object must “tell” the parent(its script) that a collision occurred.
=> Great, good idea but what if I have 10 child objects and what if I need each of them to react differently when they colide? So then I have to have 10 scripts. I would like to have one bigger script on the parent and control collision of child objects from the only one script on the parent. There must be a solution of this…
You could use the same script for all 10 child objects. The way a child object would tell the parent object, would be something like this: parentReference.CollisionHappened(this);
So, the child object is passing itself as an argument.
Could pass also an enum value, or any specific configuration set by inspector in the child objects(all using the same script).