- Home /
Question by
leeprobert · Oct 08, 2018 at 11:35 AM ·
physicsmeshcollidernormalsmeshfilter
Inverted normals of a sphere with physics
I am flipping the normals of a sphere so I can see the texture on the inside, but I also want to have the sphere with a rigid body so objects inside of the sphere will bounce off the inside geometry. The script I am using the flip the normals is here: void Start () {
Mesh mesh = this.GetComponent<MeshFilter>().mesh;
Vector3[] normals = mesh.normals;
for(int i = 0; i < normals.Length; i++){
normals[i] = -1* normals[i];
}
mesh.normals = normals;
for(int i = 0; i < mesh.subMeshCount; i++){
int[] tris = mesh.GetTriangles(i);
for(int j = 0; j < tris.Length; j+=3){
int temp = tris[j];
tris[j] = tris[j+1];
tris[j+1] = temp;
}
mesh.SetTriangles(tris, i);
}
}
The internal physics objects just fall straight through the outer sphere. How can I get the physics to work. Do I need to flip the normals on the collider mesh too?
Comment
Your answer
Follow this Question
Related Questions
Updating Dynamic Mesh's Collider is Too Slow 1 Answer
Rigidbody projectile gets stuck in two-sided Procedural mesh / mesh collider 0 Answers
other.contacts[0].normal changes over time 0 Answers
Physics.OverlapBox colliding with disabled MeshCollider 1 Answer
Physics Raycast gives hit in wrong place 0 Answers