- Home /
Separating behavior of parent and child Colliders:
In my game I have a game object that is being moved via physics and has a basic rigidbody component and collider so it won't pass through walls I have set up. The walls are just empty game objects that have box colliders on them. At first it was working just as expected, however things got frustrating when I wanted to add a game object child to the object with a collider that would allow it to destroy certain objects on contact. In order to do this I needed to make the child object is Trigger, however when I made the object a child of the parent object mentioned before, the entire object started ignoring my walls. This problem only persists when the child object is checked as a trigger, and subsides when I uncheck is trigger on the child. My question is if there is any way to separate the behavior of the child and the parent object colliders while having them move together.
Answer by Foulcloud · Aug 24, 2015 at 09:27 PM
You could separate the objects and then have the trigger follow the rigidbody.
Void Start() { GameObject firstObject = GameObject.Find("ObjectName"); }
Void Update() { transform.position = firstObject.transform.position; }
You could then put these into a new parent to keep it tidy.
Not sure if you want to do this though as you can check for collisions on the rigidbody without seting anything as a trigger. Use OnCollisionEnter() instead of OnTriggerEnter().