- Home /
Mirror flip using scale -1
When using scale -1 to flip an object, the colliders are not flipped correctly. Is there any other way to flip an object?
What kind of collider colliders are you talking about because I didn't notice anything wrong when flipping them?
Answer by johan-skold · May 15, 2010 at 04:26 PM
When flipping an object you're basically making the triangles go the other way around. I can never remember the order they're supposed to go but if they go clockwise normally, they would end up going counter-clockwise, effectively turning the mesh inside-out. A simple fix is to reverse the orders of the triangles so the mesh is turned inside-out to begin with.
using System; using UnityEngine;
public class ReverseTriangles : MonoBehaviour { public void Awake() { Mesh mesh = GetComponent<MeshCollider>().mesh; int[] triangles = mesh.triangles; Array.Reverse(triangles); mesh.triangles = triangles; } }
Note however that this makes the mesh un-stripifiable, so if you plan on combining collider meshes you cannot make a triangle strip out of them.
Edit: I might have misunderstood "not being flipped correctly" as "being broken after being flipped". If they aren't being flipped at all, that's another story.
Edit 2: I also just realized I was assuming you meant a MeshCollider. If that's not the case, I don't have a solution for you other than to put the object in question inside a parent, and giving the parent the collider instead.
Answer by Eric5h5 · Aug 07, 2010 at 10:21 PM
The colliders are flipped correctly when changing the scale in Unity to -1. If you're doing that in a modeling program, maybe it doesn't work; I'm not sure.
Answer by Matt-Downey · Dec 17, 2011 at 10:26 AM
Your problem might be solved by:
GL.SetRevertBackfacing(true);
There are still major problems with lighting (only ambient and non-realtime light will work).