dgreenheck/OpenFracture

Keep Getting Index Error

Closed this issue · 2 comments

I am trying to apply it to the walls of a simple castle and keep getting this error: I don't understand why I am getting these errors while you have letters like P and F in your sample scene. The castle wall is just another F with more holes.

IndexOutOfRangeException: Index was outside the bounds of the array. FragmentData..ctor (UnityEngine.Mesh mesh) (at Library/PackageCache/com.dgreenheck.openfracture@7edc606bae/Runtime/Scripts/Fragment/FragmentData.cs:114) Fragmenter.Fracture (UnityEngine.GameObject sourceObject, FractureOptions options, UnityEngine.GameObject fragmentTemplate, UnityEngine.Transform parent, System.Boolean saveToDisk, System.String saveFolderPath) (at Library/PackageCache/com.dgreenheck.openfracture@7edc606bae/Runtime/Scripts/Fragment/Fragmenter.cs:32) Fracture.ComputeFracture () (at Library/PackageCache/com.dgreenheck.openfracture@7edc606bae/Runtime/Scripts/Fracture.cs:164) Fracture.OnCollisionEnter (UnityEngine.Collision collision) (at Library/PackageCache/com.dgreenheck.openfracture@7edc606bae/Runtime/Scripts/Fracture.cs:79).

Error is in these lines
// Add mesh vertices
for (int i = 0; i < positions.Length; i++)
{
this.Vertices.Add(new MeshVertex(positions[i], normals[i], uv[i]));
}

You most likely do not have UV data on your mesh. Placing a breakpoint there should verify.

Yes had a same issue, regenerating UVs in blender (smart UV project) fixed it and now it works perfectly. So even if mesh doesnt use material with texture, uvs still needs to be generated. It would be nice though to have disclaimer on readme page or somewhere that generated UV data needs to be present.