Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Unity 2022.2 is now available as the latest Tech release.
    Dismiss Notice
  3. We are making some changes to the DOTS forums.
    Dismiss Notice
  4. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

[RELEASED] Cloth Dynamics

Discussion in 'Assets and Asset Store' started by Nexusmaster, Dec 9, 2020.

  1. aqualonix

    aqualonix

    Joined:
    Aug 21, 2021
    Posts:
    2
    Will this work with the bones dynamics like Dynamic Bone or Obi Rope? Will the cloth react accordingly?
     
  2. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    326
    I'm not sure what you mean, the cloth can collide with primitive objects, which are based on SDFs. Supported sdf objects are spheres, capsules, cylinders, boxes and round cones. I wrote a script that places these colliders automatically along the bones of a humanoid character.
    There is also a more detailed collision, which uses the vertices (or triangle surface points) as small spheres to collide, but this only works on high end devices, not on mobile.
     
  3. Framehacker

    Framehacker

    Joined:
    Jan 30, 2020
    Posts:
    11
    Any chance to explain this stuff for ppl who dont know hlsl? I have a custom shader form another asset but have no clue where to put this code.

    I see there stuff like subshader and passes bot no "vertex shader", and if i put that code snipped in one of the passes it doesnt work.
     
  4. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    326
    This is an example of the subshader for the Unity shader graph system. If you don't know much about shaders you can still clone a shadergraph cloth shader and edit the copy in the shader graph editor. This works with HDRP and URP. For builtin you need to know surface shaders. Which render pipeline are you using?
    Every shader has a vertex function, you need to put the cloth function code over the vertex function an call the function at the end puting in vertex and normal data. This is very basic stuff, maybe you know some coder that can help you with it. Sorry but I can't support every custom shader. There are too many ;-)
    Have a look at my cloth shaders, you will see how they implemented the code. Basically, the buffers just overwrite the vertices and normals, that's all.
     
    Last edited: Jan 5, 2022
  5. Diego_Alejo7

    Diego_Alejo7

    Joined:
    Jun 26, 2018
    Posts:
    4
    Hi, I when generate spheres collider with "automatic bone spheres" script, obtain this result: (Sin error.png)

    But when play and stop the game, the bone spheres change immediately to: (Error Play.png)

    Its a bug :(?, I use unity version 2021.2.7f1 and CD 1.7.3
     

    Attached Files:

    Last edited: Jan 6, 2022
  6. Diego_Alejo7

    Diego_Alejo7

    Joined:
    Jun 26, 2018
    Posts:
    4
    Hi, In CD it is possible change spheres colliders generated by "automatic bone spheres" in real time?. I want to try modifying 'blend shapes' of my 3D model and generate colliders of this new 'blend shapes' configuration, and repeat this many times..
     
  7. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    326
    Looks like you added the Dress to your "Mesh Collider Sources", only use the body mesh, please!
    You can turn off the ABS script before you start the play mode the update functions will be called from the Cloth script if needed.
     
  8. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    326
    ABS colliders will not be affected by the GPU Blend Shapes, but you can try using the Collision Finder, if you are not developing for mobile.

    If I have more time for this, I will try to improve the whole system, so also the Collision Finder will work on all systems...
     
  9. Framehacker

    Framehacker

    Joined:
    Jan 30, 2020
    Posts:
    11
    I have a custom URP shader, however it doesn't use Shadergraph just plain code. I tried to write a new pass just for the cloth stuff, however the shader tells me now it need a fragment shader (whatever this is). Also tried to include it in a shader function of the existing passes, but i have also trouble to figure out what i have to put in as "float3 vertex", was thinking about the :SV_POSITION but that would be a float4.


    I understand that you cant support every single custom shader, however it would be nice to have some kind of dokumentation of how an implementation could look like, with a code snipped or something.
     
  10. Kory-therapy

    Kory-therapy

    Joined:
    Jun 5, 2013
    Posts:
    46
    I was wondering if their is away to get the 2019 or 2020.1.17 build of Cloth Dynamic I was building my game with the Digital Human Skin Shader and I didn't notice it stop working on 2020.2 :( but I will need to get the first build of Cloth Dynamic. I'm building samurai game and I love the Cloth Dynamic and heretic shader then I seen the KWS Water shader I upgrade and everything stop working but I guess I can't use the water shader but I will email you here some of my work with heretic skin shader





    Thanks
     
  11. Diego_Alejo7

    Diego_Alejo7

    Joined:
    Jun 26, 2018
    Posts:
    4
    Hi again!, I tested "Projection Mask" scene using HDRP but the shader "Lit_Graph_GPUSkinningMask" don't work correctly.

    This scene without HDRP works perfect, but with HDRP my "patch" solution is edit any values of this shader during game play mode for this shader starts to work.
    (I read the documentation and I watched the video of this theme) It's a bug? :c
     
  12. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    326
    Hi Diego, i will have a look... What do you mean with your patch solution? What do I need to do to test your issue? Can you send me a test scene (with my example characters) ? You can write me a PM or an email, because this sounds like a special case... Sorry, I still don't understand what you want to do. :)
     
    Last edited: Jan 13, 2022
    Diego_Alejo7 likes this.
  13. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    326
    For other users, who might have the issue with HDRP and Projection Mask. You need to change the material's shader of the character's body manually and also update the shader parameters and the alpha clipping in the shader graph (resave it). This issue might come from the fact that the asset was published for unity 2019 and there is some bug with the emission intensity and emission color in the shader graph. This issue is solved in unity 2020 and newer.
     
  14. yukocchi

    yukocchi

    Joined:
    Jul 5, 2018
    Posts:
    7
    Hi, I still see this with the latest CD 1.7.3. Would you fix this or tell us how to fix this? Thanks!
     

    Attached Files:

    Last edited: Jan 28, 2022
  15. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    326
    Hi yukocchi,
    the teleportation problem can be manually fixed, I didn't add an automatic system yet, because it's not so high prio for me, but I can add a helper script in the next version.
    Basically you need to set the _minBlend value to 1 before you teleport and reset it after it.

    Create a script and call it ClothTeleportFix :
    Code (CSharp):
    1. using System.Collections;
    2. using UnityEngine;
    3.  
    4. namespace ClothDynamics
    5. {
    6.     public class ClothTeleportFix : MonoBehaviour
    7.     {
    8.         [SerializeField]
    9.         private GPUClothDynamics[] _cds;
    10.         [SerializeField]
    11.         private float _teleportDuration = 1.0f;
    12.         //private WaitForSeconds _waitForSeconds = new WaitForSeconds(_teleportDuration);
    13.  
    14.         public void OnTeleportEvent()
    15.         {
    16.             print("OnTeleportEvent() triggered!");
    17.             foreach (var cd in _cds)
    18.             {
    19.                 var saveMinBlend = cd._minBlend;
    20.                 cd._minBlend = 1;
    21.                 StartCoroutine(DelayBlendBack(cd, saveMinBlend));
    22.             }
    23.         }
    24.  
    25.         private IEnumerator DelayBlendBack(GPUClothDynamics cd, float saveMinBlend)
    26.         {
    27.             //yield return _waitForSeconds;
    28.             float blendTime = 0;
    29.             while (blendTime < _teleportDuration)
    30.             {
    31.                 float step = blendTime / _teleportDuration;
    32.                 cd._minBlend = Mathf.Lerp(cd._minBlend, saveMinBlend, step);
    33.                 blendTime += Time.deltaTime;
    34.                 yield return null;
    35.             }
    36.             cd._minBlend = saveMinBlend;
    37.         }
    38.     }
    39. }
    Apply it to your character like this:
    upload_2022-1-27_9-24-55.png

    Go to the Animation of your character and add the event function OnTeleportEvent before the teleport happens:
    (in the case of the fighters, almost at the end of the animation)
    upload_2022-1-27_9-24-27.png
    (You need to do this for each animation)

    Now the script will set the MinBlend and the teleport issue is gone.
    You can also edit the script and add a "blend in" coroutine if you like. Remember the blend back coroutine should then be called after the "blend in" finished.

    In the attached gif you can see the final result:
     

    Attached Files:

    yukocchi likes this.
  16. yukocchi

    yukocchi

    Joined:
    Jul 5, 2018
    Posts:
    7
    Dose CD support multiple layers of cloth in character clothes? How to use CD to simulate that?
    What is the meaning of painted red in painted object component for cloth which has CD component (do simulation) and also is in other cloth's mesh object list for collision finder (act as collider)?
     
  17. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    326
    No.
    You can only use self collision.
    From the docs: This will only apply for cloth meshes that have a paint object component:
    "The red vertices will tell the cloth sim to use the Skinning, if they are black, it will use the cloth simulation for these black vertices."
    Be careful: When you paint on a body mesh, red vertex color means "use for collision", black means "no collision".
    Check out the "Cloth2Cloth" example scene: The "ClothBlue" object has itself and the "ClothRed" object added in the collision finder list. However this can be very performance heavy.
     
    Last edited: Feb 4, 2022
    yukocchi likes this.
  18. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    326
    Ok, so here is the roadmap for the next planned updates:

    Multi Layer Collision:
    Currently I'm trying to get this working. I'm working on a simple approach that should not impact the performance so much. The trick is to use a collision plane between the cloth layered vertices. Each vertex will search for the closest vertex in the bottom layer at the init phase:



    (Planned for March 2022)

    Vertex Data Buffers (or Textures):

    Instead of using Vertex Colors I like to shift to textures or buffers, that will save these data arrays. This needs to be tested if it works on every device and also if it affects the performance. The benefit will be free vertex colors to use for something else.
    (Planned for March 2022)

    Collision Finder for Mobile and Memory improvements:
    This is a tough one, but I will try to get everything working on mobile. The benefit will be that the system uses less memory and should be a bit faster.
    (Planned for April-May 2022)

    Tearable cloth:
    Well this should be easier to solve, however it makes sense to add this after the system gets all the updates.
    (Planned for June-July 2022)

    General bug fixing:
    On top there will be also some bug fixing and improving going on as usual.

    Currently I'm very busy with other projects, from March on I will have more time for CD.
    Thank you everyone for your patience!

    All the best,
    Chris
     
    yukocchi likes this.
  19. bha_unity

    bha_unity

    Joined:
    Jun 18, 2018
    Posts:
    4
    Hey, awesome tool! I made a build with Unity 2020.3.28f1 and 2020.21f1 and it crashes on execution. It will not if I disable GPU skinning script. Is it a known bug or a workaround?
     
  20. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    326
    Hi, normally it does not crash... what are your system specs? Windows PC? Which GPU? Did you test it with an example scene? Does any example scene with GPU Skinning crash or only a specific one?
    You can also try to add the GPU Skinning shader (whichever you are using HDRP, URP, builtin) to your included shaders in the graphics settings.
    See in the CD Docs under: "Build Settings"
     
    Last edited: Feb 10, 2022
  21. bha_unity

    bha_unity

    Joined:
    Jun 18, 2018
    Posts:
    4
    Yes it's on Windows, amd ryzen 9 5950x, rtx 2080 super, 32 GB ram. The example scene looks fine. When I click update mesh objects and the GPU skinning script is generated I can build but it crashes. If I deactivate the GPU skinning script, I can run the build. The mesh is an animated skinned mesh. I also put in the build setting you have in your doc.

    edit: I used the ShaderGraphs/LitGraphCloth shader
     
    Last edited: Feb 10, 2022
  22. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    326
    Hi, I sent you a PM, so we can discuss this issue more detailed! When I figured it out, I will post the results here.
     
  23. yukocchi

    yukocchi

    Joined:
    Jul 5, 2018
    Posts:
    7
    Hi, I checked out that scene and found some problems.
    1) The yellow balls don't get force from the cloth. The simulation of CD seems single-way.
    2) There is visible gap between the red cloth and the blue cloth. Not very seamless.
    3) The blue cloth is still jittery after other objects get quite stable.
     
  24. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    326
    Well these are the limits of CD.
    1)Two way collision between GPU physics and CPU physics (from Unity) is very performance intense, I try to solve this in the ReadbackTest example scene, however this still needs improvement and also will use the last frame, so can't be that accurate.
    2) Well, you can adjust the radius settings to reduce the gab but there might be overlappings happening... this is why I want to add the multi layered system.
    3) you can try and use the damping to reduce jittering, but this is also not so easy to solve maybe you want to write your own physics system and make it better :)
     
    Last edited: Feb 11, 2022
    yukocchi likes this.
  25. AndySteelCity

    AndySteelCity

    Joined:
    Jul 25, 2020
    Posts:
    1
    Hi, After installing the Cloth Dynamics package (1.73) from the package manager in my project (version 2020.3.7f1) I'm getting some issues. Firstly, it took over 3 hours to reimport the entire project after installing the package, secondly I'm getting lots of errors concerning MonoBehaviour. e.g:

    You are trying to replace or create a Prefab from the instance 'Rigs_Holder' that contains the script 'PlayerIK_FinalIK', which does not derive from MonoBehaviour. This is not allowed.
    Please change the script to derive from MonoBehaviour or remove it from the GameObject.
    UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()

    Can you help? What do I need to do to resolve this and actually be able to use the Cloith Dynamics?

    Cheers

    Andy
     
  26. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    326
    Hi Andy, did you try what the error message says: "Please change the script to derive from MonoBehaviour or remove it" ?
    I have no "PlayerIK_FinalIK" script and no Rigs_Holder prefab in the CD asset, so I can't help you with that sorry.

    Yes, I had this Unity bug, I think it gets triggered by some Editor script or the asmdef, not sure, but I can't figure out what exactly causing it. The problem is, it does not always happen, it also depends on the project, but yes I will try to find the source. It also depends on the Unity Version, they might have fixed this issue in Unity 2022, but not sure.

    So back to your error message, I would recommend renaming the scripts (and other dependency scripts) like PlayerIK_FinalIK.cs_bak and see if you get your project running without errors, after that you can step by step find out what really caused it. At the moment I can't really help, because no CD script is involved directly. Do you get some other errors that are from CD? You can also write me a PM btw. to keep this forum page compact.
     
    Last edited: Feb 14, 2022
  27. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    326
    Looks like we could fix "bha_unity" issue by reenabling the old Input System. He had turned it off. And some CD script uses the old Input System. I will rewrite or disable this script, because it's not so necessary, it was just for the example scenes. I will upload a new version next month, maybe sooner.
    Edit: Also we found out, that the wrong shader was applied to the material. Please check if you are using the right shader for your render pipeline.
    You can also duplicate the shader file and edit it in the shader graph (if it's SRP). Also I would recommend appling the shader to the material before pressing play, then the script will not replace it. CD looks for the shader names with "skinning" or "cloth" included. Uppercase or lowercase writing works.
    The shader graph shaders needs to be updated by opening and clicking on the parameters in the shader graph, which say "update". This is the case, because I uploaded CD with 2019, but I will soon deprecate 2019 and switch to unity 2020 LTS. The 2019 version will still be available but there will be no new updates.
     
    Last edited: Feb 15, 2022
  28. yukocchi

    yukocchi

    Joined:
    Jul 5, 2018
    Posts:
    7
    Hi,
    Character skin sometimes still goes above the clothes in the ProjectionMask demo scene. How to avoid that? Thanks!
    (BellyDancer is used as controller in the Animator component of Margot for test. Notice the butt part.)
    upload_2022-2-15_17-47-41.png
     

    Attached Files:

  29. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    326
    Hi, you can adjust the "Depth Threshold" value in the Projection Mask script, if that does not work you need to increase the "triangle/vertex scale" or "Collidable Object Bias" in your Cloth Sim. I tested the ProjectionMask example scene with the BellyDancer animation, and couldn't find any overlapping. If you are using HDRP make sure the MaskCam looks like this:
    upload_2022-2-15_11-49-23.png

    here are my results with the Builtin pipeline:

    upload_2022-2-15_11-38-56.png

    upload_2022-2-15_11-39-31.png
     
    Last edited: Feb 15, 2022
    yukocchi likes this.
  30. SpencerIO

    SpencerIO

    Joined:
    Oct 8, 2013
    Posts:
    8
    Hi @Nexusmaster , I purchased the Cloth Dynamics asset and I was wondering if the RoundCones Colliders are exclusive to Cloth Dynamics?
     
  31. yukocchi

    yukocchi

    Joined:
    Jul 5, 2018
    Posts:
    7
    Hi, I'm browsing the example scenes one by one without touching anything and often get notified that I should save the modified scene. The scenes seem to be dirty just after load. (show * beside the scene name in the hierarchy window) Why is that? Thanks in advance!
     
  32. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    326
    Hi, the Round Cones are only working with the CD system, Unity does not support them. (It's not included in nvidia physX).
     
  33. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    326
    Yes, I also have this bug, but I don't know how to fix it, if you find anything let me know!
    The strange thing is, it only happens in some scenes, not with every scene. I'm guessing the Editor scripts are affecting this behaviour. It's a bit annoying, but it's harmless.
     
  34. yukocchi

    yukocchi

    Joined:
    Jul 5, 2018
    Posts:
    7
    I noticed that after saving the scene a new Lighting Settings Asset is created with the same name under the same folder as the scene. And then the problem won't show up for the scene again.
    Lighting Settings Asset is introduced in Unity 2020. I think this comes from the Unity new feature and not something to blame CD.
    So for users who are using CD in Unity 2020 and newer version, they can surely save the demo scene right after they first open it if Unity asks them to save it. Unity will only create a Lighting Settings Asset for that scene and not do any actual modification to that scene. Unity will not ask them to save the scene then if the scene is not manually modified.
    That's what I find out.
     
    Nexusmaster likes this.
  35. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    326
    Thanks! That sounds plausible!
     
  36. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    326
    I will soon add a new feature to CD:
    Body Blend Shapes that can affect the cloth:
     

    Attached Files:

  37. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    326
    However the Body Blend Shape only works when you also have a Blend Shape for the cloth, so in your 3D app you need to make a Blend Shape for the Body and the cloth.
    upload_2022-3-4_16-31-31.png
     
  38. NickFrushour

    NickFrushour

    Joined:
    Apr 11, 2011
    Posts:
    12
    Hi!

    Does CD work well with clothes that weren't generated inside Unity? For example, if there are some clothing meshes that were created in Maya or Blender, would I be able to apply the CD components to the new meshes successfully? I ask because I saw a tutorial about creating a new dress for Margot, but I haven't seen any tutorials or any information on using separate clothing meshes.

    Thanks!
     
  39. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    326
    Hi Nick,
    you can use any mesh, of course you get the best quality when your mesh is uniform, meaning all edges of the mesh have a uniform distance (Marvelous Designer does this automatically). Also the meshes should be set to 1 scale in Unity. Additionally some features of CD (e.g. surface push) only work, if your cloth mesh is skinned to your character (in Maya or Blender). The Skinned cloth should always be on top of the body mesh so the body is not visible, this should be also the case if CD is not used. As you can see in my last post, the cloth of the Blender character is always "coating" the body (no overlapping even when I change the character's pose).

    If your mesh fulfils these conditions, there should be no problem with using CD (if you are using a humanoid character setup).
     
    Last edited: Mar 11, 2022
    NickFrushour likes this.
  40. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    326
    Hi,
    I uploaded a new version (1.8.5) to the store! It includes the Teleport Fix and the GPU Blend Shapes Updates. I also added this to the docs!
    In 1.9 I will try to add the layered cloth. I will also ditch 2019 and 2020 versions
    After that 2.0 will come, which will be a redesign mainly for the collision finder, which I want to make work with mobile and also improve the overall performance.
     
    ARon_w and jjejj87 like this.
  41. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    295
    Hello

    I was checking out the demo and some videos and there is one area that concerns me about trying this product,

    It is possible to completely fix issues like the ones on your demo, for example:
    upload_2022-3-18_12-23-43.png

    The cloths seems to be overlaying within itself giving this weird result.

    The other issue I noticed in a video, the cloth seems to be very elastic:
    upload_2022-3-18_12-25-36.png

    I also noticed some clipping issues in the demo:
    upload_2022-3-18_12-26-51.png

    Thanks for helping determine if this is something that can be solved.

    Regards
     
  42. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    326
    1) This is tricky to fix but possible, currently only by blending to standard skinning for these vertices. Pixar had a paper about this topic, they detect the overlapping area and freeze the sim in this part. I like to add this, when I'm done with the collision system redesign.

    2) The streching can be reduced by clamping the velocity to a lower value e.g. 1-2 :
    upload_2022-3-18_18-32-8.png
    I found this out, after making the demo video.

    3) Well the demo is a bit old so I can't tell what the reason for the clipping is, maybe the teleport issue or the cloth settings. I also did not have the projection mask script in the demo, which I added in the newer versions. It also helps to hide some small clipping issues.

    I will soon upload a new demo, maybe with version 1.9 or 2.0. You could wait until then and see if the new demo suits you better.
     
    Hazneliel likes this.
  43. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    295
    Hello, quick question, which Skin Shader are you using?
    Thanks
     
  44. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    326
    Hazneliel likes this.
  45. Irideas

    Irideas

    Joined:
    Nov 8, 2017
    Posts:
    7
    Hello @Nexusmaster, I'm getting this error when I try to set active the GameObject of a cloth through code, I'm not really sure how to go around it. The cloth manages to get activated and shows in the scene, but just as a static object with no simulation.

    I'm using UnityEditor 2021.2.15f1 and Cloth Dynamics v1.8.5



    Code (CSharp):
    1. ArgumentException: Invalid path
    2. System.IO.Path.GetDirectoryName (System.String path) (at <feaaa6313e32495d9f259b175aa6b597>:0)
    3. ClothDynamics.GPUClothDynamics.CheckShaderKeyword (System.String strKeyword, System.Boolean isOn) (at Assets/Import Packages/ClothDynamics/Scripts/GPUClothDynamicsUtilities.cs:2514)
    4. ClothDynamics.GPUClothDynamics.SetShaderKeyword (System.String strKeyword, System.Boolean turnOn) (at Assets/Import Packages/ClothDynamics/Scripts/GPUClothDynamicsUtilities.cs:2539)
    5. ClothDynamics.GPUClothDynamics.Init () (at Assets/Import Packages/ClothDynamics/Scripts/GPUClothDynamics.cs:848)
    6. ClothDynamics.GPUClothDynamics.OnEnable () (at Assets/Import Packages/ClothDynamics/Scripts/GPUClothDynamics.cs:781)
    7. UnityEngine.GameObject:SetActive(GameObject, Boolean)
    8. MannequinClothes:ChangeCloth(GameObject) (at Assets/Project/Scripts/Mannequin Handlers/MannequinClothes.cs:107)
    9. MannequinClothes:SetClothes() (at Assets/Project/Scripts/Mannequin Handlers/MannequinClothes.cs:62)
    10. UnityEngine.EventSystems.EventSystem:Update() (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:501)
    I'm basically loading an asset bundle and assigning it to a character that is already painted and ready to wear clothes, but somehow I'm getting this error.

    It worked fine with some basics clothes at first but now that I'm trying to use some heavier ones It throw me that error.

    Thanks
     
  46. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    326
    Hi,
    I never tried asset bundles with cloth dynamics, so maybe that is why it's not working, does the same setup work without using asset bundles?

    Well the issue should be gone with the next version, but for now try to comment out the lines:
    2511-2531 and 2539-2564 in the GPUClothDynamicsUtilities.cs
    Also check if the PBDClothSolver.compute file has set the define to 0 like this:
    #define USE_UNITY_2019 0
    This should solve the issue. Most of the errors are only because I tried to make this asset compatible for 2019 till 2022, but it does not really work and cost me a lot of time. The next version will not support 2019 anymore I'm also thinking about skipping 2020. You can still use 2019/2020 version but there will be no more updates anymore.
     
    Irideas likes this.
  47. Irideas

    Irideas

    Joined:
    Nov 8, 2017
    Posts:
    7
    Hi, thanks!, that did the trick and solved my problem.
     
    Nexusmaster likes this.
  48. Irideas

    Irideas

    Joined:
    Nov 8, 2017
    Posts:
    7
    Hello @Nexusmaster, now I'm getting this error when I try to go back and forth between clothes using setActive true/false in each GameObject with the option "Use Collision Finder" enabled (It seems like it does not happen when I change to a Collidable Objects List, but I need the other option). The cloth loads, but without sim.

    I'm using UnityEditor 2021.2.15f1 and Cloth Dynamics v1.8.5



    Ps: sorry for using a picture instead of the error itself, can't access to it right now.
     
  49. ml785

    ml785

    Joined:
    Dec 20, 2018
    Posts:
    74
    Would this work for hair?
     
  50. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    326
    Hi,
    sorry for the delayed reply... Well the old CD version is not designed to do things like you do... :) But maybe this helps:
    1) Open the GPUClothDynamicsUtilities.cs
    2) Goto line 111
    3) Add this line under the function "SetCollisionFinderBuffers" in line 111:
    Code (CSharp):
    1. if (_collisionFinder._selfTrisDataBuffer == null) _collisionFinder._selfTrisDataBuffer = new ComputeBuffer(1, sizeof(int));
    Hope this helps!