Search Unity

Assets Obi Particle Based Physics (Cloth, Rope, Fluid) thread

Discussion in 'Works In Progress' started by arkano22, Jun 30, 2015.

?

Performance vs compatibility

Poll closed Oct 9, 2015.
  1. I don't care about performance, keep my data intact please.

    0 vote(s)
    0.0%
  2. I don't care if I have to re-do some stuff, as long as it runs faster.

    14 vote(s)
    100.0%
  1. RoyArtorius

    RoyArtorius

    Joined:
    Jul 11, 2013
    Posts:
    69
    Hi,
    I agree with you. It's definitely worth $50. The un even number of 47 just stirred up my math mind. :p I would've made it an even $50. :)
     
  2. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    610
    No worries, we just want to make sure the prices are as fair as possible. :)
     
  3. Onat-H

    Onat-H

    Joined:
    Mar 11, 2015
    Posts:
    66
    Hi,
    First of all thanks for the update. I'm on the 5.6 b8 and while i would understand it if you don't support it yet, i just wanted to ask you if you know why the obi cloth script throws the following error: Assets/Obi/Scripts/Actors/ObiCloth.cs(439,14): error CS1061: Type `UnityEngine.Animator' does not contain a definition for `Stop' and no extension method `Stop' of type `UnityEngine.Animator' could be found. Are you missing an assembly reference?
    I'm not a programmer so it's not easy for me to understand, and i don't know if its because of Unity 5.6 or something else. Thanks for your support!
     
  4. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    652
    Yeah I tried using it in the new beta as well. Clearly a lot has changed. That line I fixed by changing it to .StopPlayback() which I guess is replacing .Stop.

    Also, "animate physics" is broken in the new beta, so that messes it up too :|

    I'm back on 5.5 now till it's more stable.
     
  5. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    610
    HI there,

    We haven´t tried the latest beta yet, so it's not officially supported. If Unity has undergone API changes of renamed methods (as this is the case, it seems), or even has introduced new bugs, Obi might not work well with it.

    Until a beta stabilizes and changes to the API are final, (which usually happens when the version is out of beta, or close to) it doesn´t really make sense to support it.
     
  6. Onat-H

    Onat-H

    Joined:
    Mar 11, 2015
    Posts:
    66
    Ok thanks, will wait a little more then ;)
     
  7. OnlyVR

    OnlyVR

    Joined:
    Oct 5, 2015
    Posts:
    52
    Is there any update? Could you ask Asset Store what is the reason of the delay?
     
  8. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    610
    Yes! Sorry I forgot to mention it here as others did, but it's been available for a couple days. Here's the link:
    https://www.assetstore.unity3d.com/en/#!/content/81333
     
  9. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    652
    Hi Arkano. I'd like to report a bug/issue. When using "Simulate in local space", gravity is also appied in local space, which means if I rotate my character so that they are walking on the wall for instance, then gravity rotates with them.

    I suppose that I could do the maths myself and constanty update the gravity vector to point down, but I think it would be better if this was done internally. Perhaps add the option as a tick box?
     
  10. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    610
    Hi Zomby!

    This is by design, it behaves the same way as regular Unity particle systems do, for consistency. It makes sense that gravity is applied in the same space used for simulation.

    A character walking on the wall is not an usual enough use case to justify adding a special toggle for gravity. Just use solver.parameters.gravity = transform.InverseTransformDirection(worldGravity), then follow with a call to solver.UpdateParameters();
     
  11. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    652
    Hi Arkano. That gravity thing seems fair enough.

    Btw I'm not just using it for putting characters on walls. I found that turning down the "world velocity scale" was very effective at keeping the simulation under control, but it only dampens the velocity of the actual character controller moving around. When my character does an acrobatic flip, they rotate and move very fast within their own animation space.

    So I tried putting the Ubi solver script on the actual pelvis bone of the character, to turn the "world velocity scale" into a sort of "pelvis space velocity scale", which works really well at dampening the simulation during back flips etc. However it also means that gravity always pulls downwards in pelvis space :p which I will fix in the way you suggested.
     
  12. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    610
    Thanks for explaining your situation in detail, now I get the problem! In the next update I will add a new transform variable to the solver, so that you can specify which transform you want the gravity to be relative to. If this is set to null (none), then it will be always applied in world space, regardless of the simulation space.

    This way, you´d have to do nothing special in your case, and if anyone wants the gravity in any other space, they just have to provide the transform they want.
     
  13. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    610
  14. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    652
    I have a few things I want to ask about. I'm at work right now so I don't have anything in front of me but there's a couple of things I can remember from last night.

    I found that if I had two separate Obi Cloth scripts running on the same character, both using the same Obi Solver script (say one for a skirt and one for the hair), it caused the character animations to play at double speed. Maybe update was being called twice somehow. This happened both with and without "animate physics" turned on.

    Is that a valid setup, or am I meant to have two separate Obi Solver scripts running?

    I'll have some more questions later when I'm back home.
     
  15. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    652
    Looks like I still get the double animation speed even if the two Obi Cloth scripts use two different Obi Solver scripts.

    So anyway. I tried to set up a character cloth proxy.

    I want to use a different meshes for the simulation and rendered mesh. Unfortunately your trench coat example is the case where the two meshes are the same, so I had to do a lot of guess work. I wasn't sure if just the simulated mesh needed an Obi Cloth script, or both, and I wasn't sure which of the two was meant to have the Obi Cloth Proxy script.

    I made an Obi Triangle Skin Map, and I think I got all the scripts in the correct places. But, alas and alack, all I got were null references. Eventually I came across this line in the code:

    Debug.LogWarning("Cloth proxies do not work with SkinnedMeshRenderers yet.");

    So sad :( It would have been nice had the code got that far, so I would see it in the output. Have you not finished the case where both meshes are skinned and different?
     
  16. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    652
    Sorry for the tripple post, but I'd just like to point out that your man in the trench coat is over 8 foot 3 inches tall! Just over the hight of the tallest living man in the world.
     
  17. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    610
    The case where the two meshes are the same is pretty much identical to the one where each mesh is separate, the only difference being where you put the ObiClothProxy component (must be placed in the driven mesh, that its the rendered one). In the case where both are the same, the same mesh has the ObiCloth component and the ObiClothProxy, as it acts both as source and target of the skinning process.

    In all our tests this works fine too, however the target mesh must not be a skinned mesh renderer but a regular mesh, as it will be skinned to the simulated mesh by the proxy component. This is what the warning refers to. We are working on supporting skinned meshes acting as target of another skinned mesh, though.
     
  18. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    610
    Yep, 2m 15 cm. We just wanted a tall guy :)
     
  19. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    652
    I would like both meshes to be skinned meshes.

    What sort of time frame are we looking at to get that in?
     
  20. DSL-TailorIt

    DSL-TailorIt

    Joined:
    Jan 2, 2017
    Posts:
    6
    Hello!

    I haven't seen this mentioned yet, but does Obi Cloth work for WebGL (or are there any plans to allow that)? I know the blog does not list it as supported, but I'd like to be sure.

    Thank you kindly. :)
     
  21. james14123

    james14123

    Joined:
    Jan 22, 2017
    Posts:
    20
    Hello,
    In OBi3.0, when i want to use the pin constraints with the Skinned Mesh Renderer(include collider and rigidbody elements) which is animated and i also add collider to obiSolver. But the result is unity broken.

    Do pin constraints only work with Mesh Render not Skinned Mesh Renderer?
    Can you give some advice? Thanks
     
  22. OnlyVR

    OnlyVR

    Joined:
    Oct 5, 2015
    Posts:
    52
    Hi Arkano,

    Could you add this scene in the demo scenes or provide all settings details? Dropping the script "ObiClothDragger" on the cloth is clear but I don't understand how you achieved the perfect realism in cloth+collider.


    Thanks.
     
  23. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    610
    Well, I already implemented it yesterday :). I´m trying to squeeze in a few more bug fixes, and will upload a new version the next Monday/Tuesday.
     
    Last edited: Feb 22, 2017
    hopeful likes this.
  24. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    610
    Never tried! As long as WebGL supports loading native libraries, it should work. However I won´t bet anything before testing it. I will add a task to our issue list, so that we know for sure whether it works or not.
     
    Last edited: Feb 22, 2017
  25. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    610
    Well, the collider is just a regular MeshCollider. Nothing too special about the setup, just a couple points:

    - Distance constraints: parallel update mode, 20-30 iterations. Parallel mode ensures smooth tension distribution, and 30 iterations because the resolution of the cloth is quite high and will stretch with fewer iterations.

    - Fairly low gravity to prevent overstretching. That, or fix a few particles around the waist and use tether constraints. In this particular case, the dress was 100% simulated and only shoulder collisions prevented it from falling to the floor, so I used a gravity of like -3.0 m/s2, no tethers.

    Also (and I say this because A LOT of people approach me with this question): you cannot use a MeshCollider with a skinned, animated character. Not Obi's limitation, but Unity's. Or more precisely, a general limitation of how realtime clothing is approached for games, so not Unity's fault either. It makes no sense performance-wise for a character to use a MeshCollider even if you could. You need to use a hybrid skinning/simulation approach to ensure robustness with a tight performance budget (which is what skin constraints are for), and maybe a few capsule colliders to approximate the shape of your character limbs. :)

    If your character is completely static (mannequin, statue, or similar) then it is perfectly fine to use a MeshCollider, like I did in this example.
     
    Last edited: Feb 22, 2017
  26. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    610
    Hi there! Can you provide more details, or possibly even a crash log? I tried this same scenario but couldn´t replicate the problem.

    cheers!
     
  27. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    652
    Fantazmic!

    Were you able to reproduce my problem with character animation running at double speed when you have two Obi Cloth scripts running?
     
  28. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    610
    That's one of the bugs I´m trying to get squashed before I upload the update. It is caused by a dumb design decision that's totally my fault. I made the cloth component update the animator automatically in FixedUpdate() to avoid users having to change the animator update mode manually, but of course this means that if you have two cloth components using the same animator, it will get updated twice. I´ll just need to make sure each animator only gets updated once per frame.
     
    Zomby138 likes this.
  29. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Posts:
    669
    Hi,

    Really cool asset.

    I'm trying to understand the obi proxy function, but when I create an obi triangle skin map and fill it with values, I get error in console:

    The proxy doesn't seem to react to obi entity deformation.

    edit:
    The provided proxy example scene does not work either.
    I'm on Unity 5.5.1f.
     
    Last edited: Feb 23, 2017
  30. DSL-TailorIt

    DSL-TailorIt

    Joined:
    Jan 2, 2017
    Posts:
    6
    Thank you! I'll be on the lookout for news on this matter. ;-)
     
  31. GameKitten

    GameKitten

    Joined:
    Sep 16, 2012
    Posts:
    15
    Hi,

    Thanks for the new clothing system !

    I had some success with the basic skinned cloth setup, with colliders,

    But I didnt manage to get the proxy cloth working.
    Looks like skin map painting mode doesnt work for me, there is no brush, none of the buttons in the panel work, maybe i forgot something vital in the process ?

    Any idea ?

    I made a recording that shows the black screen when trying to paint the skin map :



    And the crash when clicking bind lol.

    Edit : The skirt proxy normals are inverted, thats why i enabled the visualization tool, that brings the green wireframe.

    Edit 2 : i can open the sample trenchcoat skin map, and paint it without any problems, the problem may come from my setup, or the meshes i use. Does it matter if the target mesh contains multiple separated parts ? Should i split the mesh and use one skin map for each part ?
     
    Last edited: Feb 23, 2017
  32. CrashElements

    CrashElements

    Joined:
    Jun 19, 2015
    Posts:
    2
    hey arkano22

    this might be a dome question but is there any way i can get a camera to follow my softbody ball? i am making a physics based game and have all the components working but i cant get the camera to follow my solver or the soft body
     
  33. GameKitten

    GameKitten

    Joined:
    Sep 16, 2012
    Posts:
    15
    I did another test with a simple Flag, same problem, proxy skin map paint viewport goes black.
    Tried various setups : export Model as FBX, Blend.

    Following the doc here : http://obi.virtualmethodstudio.com/tutorials/proxycharactercloth.html

    No matter the mesh i use. When i create the obi mesh topology, and the skin map. Even setting the source and target as the same mesh, still black frozen window.

    obi_cloth_errors.jpg

    So something is wrong with the skin map editor code.
    I use Blender to export FBX, and when i tried with the Blend file itself, had some weird rotation with the flag cloth mesh, render mesh was ok.

    Problem could come from Blender ?
    Also noticed a vertex that is fixed to the origin for some reason in both tests.
     
  34. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    610
    Hi there,

    Unity serialization played a trick on me. I could not reproduce this at first because Unity was storing a non-null value at one of the public members of the ObiTriangleSkinMap class, masking the error for any non-new skin map asset. I just had to create a new one from scratch, and boooom.

    I´ve fixed it. Replace ObiTriangleSkinMap.cs with the one I´m attaching, and it should work. This fix will be included in the next update.

    cheers!
     

    Attached Files:

  35. GameKitten

    GameKitten

    Joined:
    Sep 16, 2012
    Posts:
    15
    Hi,

    Thanks for the fast fix !

    The skin map editor is working now. And Binding works.

    Then there is another error with the mesh filter, it says i probably forgot to assign the shared mesh, but i double checked. All fields are assigned.

    s1.jpg

    s2.jpg

    s3.jpg
     
  36. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    610
    Hi Renaud,

    Using a skinned mesh renderer as proxy target is not supported in the current version (you´d need to use a regular meshrenderer for the detailed version of the skirt). See my responses above to Zomby138. Next week I will upload an update that allows this.

    cheers!
     
  37. GameKitten

    GameKitten

    Joined:
    Sep 16, 2012
    Posts:
    15
    oh, i'll try it, thank you.
     
  38. CrashElements

    CrashElements

    Joined:
    Jun 19, 2015
    Posts:
    2
    arkano22

    is there any way for the camera to follow a inflation ball? i cant seem to track the solver or the cloth sim transfor and if i make it track a partical the sim stops. im making a game where u have to use over presser to inflate the ball to make it bounce and make it over obsticals and interact with objects. i just cant get the camera to follow the sim
     
  39. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    610
    Also
    Hi! The solver is just an "overlord" object, in charge of updating the simulation ,but does not move around the scene at all, nor does it care about its position. The actor (cloth ball in this case) spawns the particles that make up the object, and while fixed particles will stay in place relative to the actor's transform, free particles will roam freely around the scene.

    So there's no notion of "transform" of an actor's particles, since as a whole they don´t really have a clear position, rotation or scale. More technically: the deformation of an actor cannot be expressed using an affine transformation.

    You´ll have to decide what you want to consider as the ball's "position" (the average position of all its particles is a good start) and write a small script that calculates it: iterate over all particle positions and find their average. You can then just tell the camera to follow that position.
     
  40. GameKitten

    GameKitten

    Joined:
    Sep 16, 2012
    Posts:
    15
    I tried with the mesh renderer,

    With a simple flag model the binding works

    But with the skirt mesh i get these spikes :

    s10.jpg

    Then i tried assigning channel 0 to the back of the skirt, and i had some artefacts. Vertex displaced far under the ground.
     
  41. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    610
    Hi renaud,

    Make sure the scale of your mesh transform and the scale of the topology match. I can see in your inspector that your mesh scale is non-uniform (99,100,100). The ideal set up would be to set your import scale to 100 in the mesh import settings, that way your transform scale will be 1,1,1 and you won´t have to worry about scaling issues.

    The spikes appear because the topology probably has a scale of 1, but your mesh is 100 times larger, so you have a very tiny skirt trying to follow a really large animation and the constraints go haywire.

    In general, try to be scrupulous with scaling when you work with cloth. A cloth simulation cannot be scaled in the usual sense of the word (not Obi's limitation, true for pretty much all solvers) so if your character, cloth and topology scale don´t match, you'll be in trouble.

    cheers,
     
    Last edited: Feb 24, 2017
  42. wetcircuit

    wetcircuit

    Joined:
    Jul 17, 2012
    Posts:
    1,006
    I need to build a strand of lights like this:
    Unknown-4.jpeg

    Sorry for my obtuseness, but can I use Obi Rope for this purpose? Can I attach rigid objects evenly spaced along a rope and attach each end of the rope to a pole? Will the lightbulbs hang as expected?

    They don't really need to "swing" or be dynamic, probably just "frozen"…, but assuming I want to eventually put in some physics (wind, collision) would that also work?
     
  43. GameKitten

    GameKitten

    Joined:
    Sep 16, 2012
    Posts:
    15
    Damn again these scale issues with blender and fbx export. I stopped working with unreal engine, and Nvidia Apex clothing tool because of that, spent the last month trying to make the damn cloth work. Fbx exporter having all kind of issues with scaling, object hierarchy, bone sizes, etc. Then when it worked in Nvidia Clothing tool, importing the Apx/apb file in unreal resulted in the same mess of spikes.

    Just boring.
     
  44. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    610
    Hi!

    Sure, you need to use pin constraints for this task. Add rigid bodies to the lamps, then pin them to particles along the rope. Just make sure that there are no large mass ratios between particles and lamps (don´t hang 1kg lamps from a 5 grams particle for instance, as that will be highly unstable).
     
    wetcircuit likes this.
  45. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    610
    I know. Thought one could escape from or at least work around this kind of problem myself when I started developing Obi, but turns out it's just the way it is. Actually Apex is a really good tool when you learn to use it (though Unity's integration is kinda lame...), but sadly there's no quick way to ease the pain.

    You´ll develop a keen eye for this stuff with time, though. Things like transform freezing, joint orientations, export units... just don´t seem to work the way you expect or want them to at first, but with practice you´ll learn to identify issues pretty quick. If you need help I´m glad to offer it :)

    Edit: transform freezing (Maya terminology) or transform application (Blender terminology) is a critical thing to understand when facing scaling issues. Freezing or applying a transform to an object will multiply all vertex positions by the current transform scale, and reset the scale value to 1. This keeps your object size intact, but the scale will be 1 when exported, making it easier to control object size with Unity's import mesh settings and minimizing scaling issues. This also works for position and rotation, and usually you can apply it separately for each one.

    Maya: Modify->Freeze transformations
    Blender: Object->Apply->Scale,rotation, position, etc.
     
    Last edited: Feb 24, 2017
  46. petersx

    petersx

    Joined:
    Mar 5, 2015
    Posts:
    215
    Hello,
    I just bought Obi Clothes 3.0. There's no chance to get it working in latest beta 5.6 ?
     
  47. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    610
    Haven't tried it with the beta yet. Probably only a few naming issues are stopping it from working, but don't have time to test it right now. Use 5.5 (which is officially supported) or wait a bit until I can test and fix in 5.6.

    cheers!
     
  48. petersx

    petersx

    Joined:
    Mar 5, 2015
    Posts:
    215
    Thanks for superfast reply. I'll try with latest 5.5.1
     
    arkano22 likes this.
  49. VictoryWorks

    VictoryWorks

    Joined:
    Oct 2, 2015
    Posts:
    6
    Hi
    I see that in your "Obi Cloth 2.X for Unity" video at ~45 seconds you show a simple boat being propelled by a sail as it fills with wind.
    Is wind effecting cloth still supported in 3.x and what object/s do you use to apply that wind?
    Is it possible to have many wind objects that effect only specific cloth objects and is the propulsion force optional or does it always apply a force to any attached objects?
    My scenario is that I need to be able to apply different scripted wind forces to cloth sails that are close together but I only want the visual effect on the cloth - I don't want any forces applied to the yards, masts, etc. as that is handled in a complex set of calculations separately.
     
  50. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    610
    Hi there! Yes, wind is still supported, and it uses custom wind zones in 3.x (ObiAmbientForceZone and ObiSphericalForceZone components), instead of the simple wind direction vector that was used in 2.x. The boat example was done attaching the sail corners to the boat using pin constraints (which transfer energy between the boat and the sail in both directions, which enables the sail to propel the boat when wind is blowing).

    For your scenario you can simply fix the corners of the sails in place. This will ensure they stay in place relative to their parent transform (the boat) and still allows wind to affect the cloth, but forces generated by it won´t affect the boat at all.