- Home /
Mirroring a game object with children without messing up box colliders
I have a fairly complex object made out of cubes and I want to create a mirrored copy of it. I am attempting to do this by setting the scale to -1 on the x of the transform for the mirrored version of the object. Unfortunately, due to the nature of the object (many children rotated and positioned around in different ways) the box colliders get messed up. They are sitting at the wrong angles after flipping on the x. Is there a way in script to correctly mirror a game object without messing up the colliders?
colliders ok:

colliders goofed after mirror:

Why can't you copy the whole parent object and rotate the whole thing 180 degrees around the y axis?
That wouldn't be a mirror image, it would be rotated and all the children would be at the same angles as the original. I need all the angles flipped so left becomes right.
Rotating the parent by 180 degrees will flip the angles of the children, as long as they are angled with respect to the parent... try it out.
It isn't the same. Compare the angles of this image to the 2nd image I posted:

Answer by alexander11 · Oct 21, 2014 at 12:05 AM
this may help
http://answers.unity3d.com/questions/581430/how-to-properly-flip-2d-character-with-new-unity43.html
This is a collection of game objects with rigidbodies. They are also 3D, not 2D. The post you linked mentions "none of this works with rigidbodies" and advises people to stick with 3D, which is what I'm doing, but rotate 180 degrees, which is not a mirror image.
Even in this link it says the cleanest solution is to rotate the entire system by 180 degrees around the y axis to "mirror" it. That is your solution.
I guess I'm confused then. What does "rotate the entire system" mean, and how does one do it?
Answer by aitchest-of-dees · Oct 30, 2014 at 12:13 AM
In case anyone runs into this, here's an answer, though I really hope it isn't the answer. I ran with my interpretation of what mwbranna said "rotating the entire system", though in actuality it ended up being "rotate the negative y angle of every child object and position each object at the negative x position, having put all the objects into a separate list before doing any of this because the whole child-parent relationship will mess things up otherwise". That's the short version of the answer, anyone looking for more can check out a video demonstration of the problem and my solution here: https://www.youtube.com/watch?v=qtq5nY04V4g&feature=youtu.be
Your answer