Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Impossible to write cloth LOD due to cloth.vertices being readonly

Discussion in 'Physics' started by chanfort, May 29, 2020.

  1. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    I am currently writing cloth LOD which would turn cloth into static mesh at large distances from camera and back into simulated cloth when getting close to it. There are no issues when creating static mesh, I am just disabling GameObject with skinned mesh renderer and enabling static mesh game object with overwriting vertices from cloth:

    Code (CSharp):
    1. meshFilter.mesh.vertices = cloth.vertices;
    However, I am experiencing issues while switching back to cloth due to cloth.vertices being as readonly:

    Code (CSharp):
    1. cloth.vertices = meshFilter.mesh.vertices;
    This is necessary as disabling and enabling game object resets cloth to initial state. So was wondering if anyone tried to solve similar problems arising due to cloth.vertices being as readonly?

    I also didn't find out anywhere if it would be possible to persist cloth state so that each time disabling and enabling cloth game object (or the same way cloth component), it would not fallback to its initial state.
     
    Last edited: May 29, 2020