Problem optimization SetActive and Cloth
Hi everyone, I work on a mobile project where i use the component "Cloth" of unity to create a Jelly effect on a cube . But here is the problem : when i activate the Gameobject that contain that component with "SetActive(true)" i get a huge lag
However in play mode, if i activate the gameobject via the editor, there is no lag .
So , here is what i need: i need to activate/desactivate those object because i use a "pool". And also , desactivate the component "cloth" doesn't stop the physics of this component.
Thanks guys
Are you calling Setactive(true); many times or just once? Remember this depends on whether its in a loop or a function which gets called many times (such as Update() ).
Is your Setactive within a LateUpdate() or attached to an object being moved non-physically? By that I mean are you moving or rotating it by moving the transform directly?
If it is not within LateUpdate() then try placing it there.
EDIT: I just read something about interactive cloth. Its very inefficient regardless and the Unity dev $$anonymous$$m is phasing that one out in future versions. Fortunately there's an alternative: skinned cloth. Try that one!
This is what I read: http://blogs.unity3d.com/2014/07/08/high-performance-physics-in-unity-5/
Answer by sartubakia · Jan 03, 2018 at 08:47 PM
Same prolem, when i hide cloth parts on character. I use different skins, cloth does not work after enable gameobject on cloth component.
Only solution is disbale and then enable cloth component, but for me its crash Unity
Your answer
![](https://koobas.hobune.stream/wayback/20220612053008im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
NullPointException Object not found, caused by a variable not accepting value? 0 Answers
How to remove added component from prefab after game is stopped ? 1 Answer
Why can't you add editor scripts to GameObjects even if the tag is EditorOnly? 0 Answers
Adding created component to game object. 0 Answers
Is there a way to refer to the only script the object has without naming the script? 2 Answers