So Im using a cloth component for my character’s cloak, but evertime I play the game in the editor, mesh colliders keeps getting added, I dont know whats causing this, there’s no script attached to the cloak. Is this normal for cloth component? Or a bug?
Im using unity 2017.3.0b1 for linux
It’s a bug and you should go vote on it in the issue tracker so it gets attention. I’m not sure voting makes it get fixed any faster but I know it’s been a problem before
I believe the only reason it’s needed is to detect selections with the cloth editor. I put this script on an object to avoid a build up of mesh colliders… I can only say it works for me and I don’t offer support or think that it’s the best way to handle this. It just looks for them all and deletes all but the first one in the returned array:
[ExecuteInEditMode]
public class EditorTempRemoveColliders : MonoBehaviour
{
// editor only temporary bug fix that looks for mesh colliders created by a Cloth Component and deletes them, leaving only the first one found.
#if (UNITY_EDITOR)
public int count;
private void Update()
{
MeshCollider[] colliders = GetComponents<MeshCollider>();
for (int i = 1; i < colliders.Length; i++)
{
count++;
print("Destroyed " + colliders *+ " as " + count + " destroyed.");*
DestroyImmediate(colliders*);*
}
}
#endif
}
I have the same problem, but I am thinking it may got to do with combination of skinned renderer and cloth. If I apply the prefab, it keeps adding more and more of the same mesh colliders!!! Insane!
Hello @amiel_ace, @castor76 and @Pinkuboxu,
I have the same issue. Cloth component is simply not working anymore on version 2017.3.
If you add the @Pinkuboxu script you can avoid problems in Editor.
But the Cloth still doesn’t work at runtime, even when the game is builded.
In order to force Cloth component to work, I found this solution:
Simply disable the cloth component on the prefab. Once the gameObject your Cloth Component is in have been instantiated in the scene, enable it by script with something like this:
_clothGameObject.GetComponent().enabled = true;
I’m my case saving prefabs with cloth can sometimes add 1 or hundreds of mesh colliders to the associated objects. Most of the time just 1, but if it lags you’ll get hundreds added.
I would love to send my 10 votes to the proper issue tracker if I could find it.
Here is my script which I just tick the active button and it will clear them at runtime instead of dumping it in the update, then you can hit apply while your game is running.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DelMesh : MonoBehaviour {
// Use this for initialization
void OnEnable () {
Component[] joints = GetComponents<MeshCollider>() as Component[];
foreach(Component joint in joints)
Destroy(joint as MeshCollider);
}
// Update is called once per frame
void Update () {
}
}
I get multiple mesh colliders even if I disable the cloth script and reenable at runtime. Is there really no fix for this from the Unity team? Bug report states it’s “fixed in 2018” but how is that a “fix” if 2018 isn’t the latest stable version.
Do they ever issue patches for things like this? It breaks our game!
Same problem here, in Unity 2017.3.1f1