Posts: 38
Threads: 8
Joined: Sep 2018
Reputation:
0
Hi, thanks for the reply. Just purchased Obi cloth.
I'm trying to create a slime simulation game. This is the reference game. Have a few questions regarding the same:
1. Can a soft body cloth surface I make react to user's finger touch as shown in reference? If so, can it create a "hole" in the shape of a finger when pressed on?
2. Also, does the cloth surface allow mixing of colours on runtime? The reference game I showed also has a feature where a colour can be gradually mixed onto the slime using user's finger.
3. How do I turn gravity off for the cloth? I want it to react to touches and behave like a slimy fluid, without falling down due to gravity. (As if the cloth is actually a slime fluid kept in a bowl) I read the manual but didn't get a clear picture.
Posts: 6,321
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
09-09-2018, 11:32 AM
(This post was last modified: 09-09-2018, 02:36 PM by josemendez.)
(09-09-2018, 06:06 AM)arrnav96 Wrote: Hi, thanks for the reply. Just purchased Obi cloth.
I'm trying to create a slime simulation game. This is the reference game. Have a few questions regarding the same:
1. Can a soft body cloth surface I make react to user's finger touch as shown in reference? If so, can it create a "hole" in the shape of a finger when pressed on?
2. Also, does the cloth surface allow mixing of colours on runtime? The reference game I showed also has a feature where a colour can be gradually mixed onto the slime using user's finger.
3. How do I turn gravity off for the cloth? I want it to react to touches and behave like a slimy fluid, without falling down due to gravity. (As if the cloth is actually a slime fluid kept in a bowl) I read the manual but didn't get a clear picture.
1.- Yes, it is up to you to implement such system. You have access to particle positions/velocities, you should simply modify them when the user presses the screen. Use Unity's input system to achieve this, in conjunction with Obi's particle getters/setters:
http://obi.virtualmethodstudio.com/tutor...icles.html
2.- This has nothing to do with the physics engine/cloth simulator, as it is some sort of "paint" mode. It is completely up to you to implement this. The cloth mesh is a regular Unity mesh, to achieve this you could use per vertex colors, or textures combined with a custom shader.
3.- Simply reduce the solver's "gravity" to zero. See:
http://obi.virtualmethodstudio.com/tutor...olver.html
Posts: 38
Threads: 8
Joined: Sep 2018
Reputation:
0
(09-09-2018, 11:32 AM)josemendez Wrote: 1.- Yes, it is up to you to implement such system. You have access to particle positions/velocities, you should simply modify them when the user presses the screen. Use Unity's input system to achieve this, in conjunction with Obi's particle getters/setters:
http://obi.virtualmethodstudio.com/tutor...icles.html
2.- This has nothing to do with the physics engine/cloth simulator, as it is some sort of "paint" mode. It is completely up to you to implement this. The cloth mesh is a regular Unity mesh, to achieve this you could use per vertex colors, or textures combined with a custom shader.
3.- Simply reduce the solver's "gravity" to zero. See:
http://obi.virtualmethodstudio.com/tutor...olver.html
Thanks! I've almost achieved what I was looking for. Just one last query.
When I create a new sphere gameobject, Add a sphere collider to it, then add Obi collider component, then when I try to touch the "Slime" cloth soft body with this sphere, the body reacts to it by deforming slightly, but if I push this sphere deeper into the slime, the sphere simply goes through this body.
This sphere is basically used to represent the user's finger pressing on the slime.
How do I stop the sphere from passing through the slime soft body and only make the slime deform when pressed on with the sphere?
Posts: 6,321
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
10-09-2018, 11:41 AM
(This post was last modified: 10-09-2018, 11:46 AM by josemendez.)
(10-09-2018, 11:17 AM)arrnav96 Wrote: Thanks! I've almost achieved what I was looking for. Just one last query.
When I create a new sphere gameobject, Add a sphere collider to it, then add Obi collider component, then when I try to touch the "Slime" cloth soft body with this sphere, the body reacts to it by deforming slightly, but if I push this sphere deeper into the slime, the sphere simply goes through this body.
This sphere is basically used to represent the user's finger pressing on the slime.
How do I stop the sphere from passing through the slime soft body and only make the slime deform when pressed on with the sphere?
For the sphere to react to slime, you'd need to apply physics to the sphere too (add a rigidbody component, so that it can be "pushed" by the cloth), then control it using forces instead of setting its position directly. A collider alone won't do, as it doesn't give the sphere any physical properties (mass, velocity, torque, etc). Depending on how you've implemented input, controlling the sphere via forces can be a bit awkward. You could also attach the sphere to the users' "finger" using a spring or a similar physics constraint.
Now, assuming your slime is a simple rectangular plane, an alternative would be to "clamp" how deep the sphere can be in relation to the slime plane. For instance, if your slime plane is at Z = 0 and its normal points to -Z, then clamp the sphere position so that it cannot move towards positive Z (pass trough the slime). No need to add a rigidbody or use forces, so this is probably the easiest way if my assumptions about your project are correct.
Posts: 38
Threads: 8
Joined: Sep 2018
Reputation:
0
10-09-2018, 11:55 AM
(This post was last modified: 10-09-2018, 12:29 PM by arrnav96.)
(10-09-2018, 11:41 AM)josemendez Wrote: For the sphere to react to slime, you'd need to apply physics to the sphere too (add a rigidbody component, so that it can be "pushed" by the cloth), then control it using forces instead of setting its position directly. A collider alone won't do, as it doesn't give the sphere any physical properties (mass, velocity, torque, etc). Depending on how you've implemented input, controlling the sphere via forces can be a bit awkward. You could also attach the sphere to the users' "finger" using a spring or a similar physics constraint.
Now, assuming your slime is a simple rectangular plane, an alternative would be to "clamp" how deep the sphere can be in relation to the slime plane. For instance, if your slime plane is at Z = 0 and its normal points to -Z, then clamp the sphere position so that it cannot move towards positive Z (pass trough the slime). No need to add a rigidbody or use forces, so this is probably the easiest way if my assumptions about your project are correct. Thanks for the detailed response. As mentioned earlier, I could achieve the "deformation" of the cloth using the sphere using the same technique you mentioned. For now during testing, I'm just manually moving the sphere towards the cloth using gizmos in play mode.
The cloth does react and get pressed. The issue is, after a certain point of the sphere pressing, the cloth simply lets the sphere pass through it and starts regaining it's shape. It's as if the sphere get's "swallowed" into the cloth. How do I avoid this behavior?
How do I set up the cloth such that it does not let any object pass through it now matter how deep an object is pressed into it? I have both rigidbody and collider components on the sphere as well as cloth.
After further testing, I've been dropping the sphere onto the cloth from a height. My observations are -
1. If sphere rigidbody mass is heavy (1 or 10), on dropping, it bends the cloth momentarily then just passes through and keeps falling into space.
2. If sphere mass is very light (0.01), on dropping, it bends cloth and cloth stops it from passing through. Sphere stays on top of cloth.
3. If sphere with light mass stays on cloth, then if I try moving the sphere with gizmos in scene view, it passes through cloth again and falls.
Why is the cloth not able to stop heavy weight or sudden movement objects?
Also, all particles on all four edges of the cloth plane are fixed.
Posts: 6,321
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
10-09-2018, 01:45 PM
(This post was last modified: 10-09-2018, 01:54 PM by josemendez.)
(10-09-2018, 11:55 AM)arrnav96 Wrote: Thanks for the detailed response. As mentioned earlier, I could achieve the "deformation" of the cloth using the sphere using the same technique you mentioned. For now during testing, I'm just manually moving the sphere towards the cloth using gizmos in play mode.
The cloth does react and get pressed. The issue is, after a certain point of the sphere pressing, the cloth simply lets the sphere pass through it and starts regaining it's shape. It's as if the sphere get's "swallowed" into the cloth. How do I avoid this behavior?
How do I set up the cloth such that it does not let any object pass through it now matter how deep an object is pressed into it? I have both rigidbody and collider components on the sphere as well as cloth.
After further testing, I've been dropping the sphere onto the cloth from a height. My observations are -
1. If sphere rigidbody mass is heavy (1 or 10), on dropping, it bends the cloth momentarily then just passes through and keeps falling into space.
2. If sphere mass is very light (0.01), on dropping, it bends cloth and cloth stops it from passing through. Sphere stays on top of cloth.
3. If sphere with light mass stays on cloth, then if I try moving the sphere with gizmos in scene view, it passes through cloth again and falls.
Why is the cloth not able to stop heavy weight or sudden movement objects?
Also, all particles on all four edges of the cloth plane are fixed.
You're describing how mass works in real life: when two objects of different mass collide, they push each other with the same force, but the resulting acceleration for each object depends on its mass:
In layman's terms: the heaviest object will "push" the lightest one.
In your case: when a heavy ball falls on top of light cloth, it will displace cloth vertices out of its way much more easily than a light ball would. Note that the "stiffness" of the cloth is the same in both cases, so the cloth can easily sustain a light ball, but not a heavy one. This is the reason why heavier objects will pass trough the cloth: it is simply not stiff enough to withstand the weight.
Note that you can set the mass of the cloth in a per-particle basis using the particle editor. So if you need the ball to be heavy, just make the cloth accordingly heavy so that it will resist the weight of the ball. If you really need light cloth to be able to withstand the weight of a very heavy ball, increase the amount of distance constraint iterations (and/or solver substeps) to allow the solver to spend more time on making the cloth stiff. See:
http://obi.virtualmethodstudio.com/tutor...olver.html
In the general case, pretty much all physics engines have trouble with high mass ratios. The typical practical limit is 1/10: no object should be more than 10 times heavier than the lightest one.
Also note that placing a ObiParticleRenderer on your cloth is a great way of debugging collisions, as it allows you to see cloth particles:
http://obi.virtualmethodstudio.com/tutor...ering.html
Posts: 38
Threads: 8
Joined: Sep 2018
Reputation:
0
10-09-2018, 03:47 PM
(This post was last modified: 10-09-2018, 03:53 PM by arrnav96.
Edit Reason: Attachment
)
(10-09-2018, 01:45 PM)josemendez Wrote: You're describing how mass works in real life: when two objects of different mass collide, they push each other with the same force, but the resulting acceleration for each object depends on its mass:
In layman's terms: the heaviest object will "push" the lightest one.
In your case: when a heavy ball falls on top of light cloth, it will displace cloth vertices out of its way much more easily than a light ball would. Note that the "stiffness" of the cloth is the same in both cases, so the cloth can easily sustain a light ball, but not a heavy one. This is the reason why heavier objects will pass trough the cloth: it is simply not stiff enough to withstand the weight.
Note that you can set the mass of the cloth in a per-particle basis using the particle editor. So if you need the ball to be heavy, just make the cloth accordingly heavy so that it will resist the weight of the ball. If you really need light cloth to be able to withstand the weight of a very heavy ball, increase the amount of distance constraint iterations (and/or solver substeps) to allow the solver to spend more time on making the cloth stiff. See:
http://obi.virtualmethodstudio.com/tutor...olver.html
In the general case, pretty much all physics engines have trouble with high mass ratios. The typical practical limit is 1/10: no object should be more than 10 times heavier than the lightest one.
Also note that placing a ObiParticleRenderer on your cloth is a great way of debugging collisions, as it allows you to see cloth particles:
http://obi.virtualmethodstudio.com/tutor...ering.html On testing further, I tried keeping mass of sphere and slime equal, with respect to what you just mentioned.
I've tried keeping both in same phase as well as different phases. I've tried changing thickness of slime. I've tried changing stiffness of the slime. Literally everything is giving the same result - The sphere passes through.
The sphere STILL passes through after bending the slime. I've kept both their masses as "1". Also both use primitive colliders. The slime uses a Box collider for it's plane. The sphere uses a sphere collider.
I've attached the settings in their respective inspectors, as well as the arrangement of the two gameobjects.
This is getting very confusing. I understand that physics engines have trouble with collision tunneling. But that's with huge mass ratios or very high velocities. I don't understand why such a simple simulation results in the object passing through.
Posts: 6,321
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
10-09-2018, 03:56 PM
(This post was last modified: 10-09-2018, 04:04 PM by josemendez.)
(10-09-2018, 03:47 PM)arrnav96 Wrote: On testing further, I tried keeping mass of sphere and slime equal, with respect to what you just mentioned.
I've tried keeping both in same phase as well as different phases. I've tried changing thickness of slime. I've tried changing stiffness of the slime. Literally everything is giving the same result - The sphere passes through.
The sphere STILL passes through after bending the slime. I've kept both their masses as "1". Also both use primitive colliders. The slime uses a Box collider for it's plane. The sphere uses a sphere collider.
I've attached the settings in their respective inspectors.
This is getting very confusing. I understand that physics engines have trouble with collision tunneling. But that's with huge mass ratios or very high velocities. I don't understand why such a simple simulation results in the object passing through.
Hi,
Changing the phases will have no effect over how collisions are resolved. It is used to simply filter out collisions with certain objects.
Thickness will simply alter the size of the collider.
None of these settings will change how the cloth behaves in any way.
You're using just 3 distance constraint iterations, and 1 solver substep. Try increasing both of them as I suggested in the previous message : 5 iterations, 2 substeps.
Cloth is made out of small spherical particles sewn together by distance constraints (use a ObiParticleRenderer to see them at runtime). If a relatively object is placed on top of the cloth, the object will displace the particles very easily and open gaps between them, trough which it can slip.
Increasing the amount of iterations or substeps will allow the solver to spend more time calculating in order to make the constraints that keep particles together more strong, so that it will resist heavier loads on top of it. Note that setting the "stiffness" parameter that all constraints have to the maximum will only allow the solver to make them as stiff as possible within the current iteration budget. If the budget is too low, you will have to increase the iteration count to give the solver a chance to reach the desired result.
This is how all game physics engines work, try this experiment in Unity: place a 1000 kg box on top of a 1 kg box, hit play to watch it sink and/or explode. To fix this, go to the physics manager and crank up the amount of solver iterations (the default is 6 which is too low for this scene). See:
https://docs.unity3d.com/Manual/class-Ph...nager.html
Posts: 38
Threads: 8
Joined: Sep 2018
Reputation:
0
(10-09-2018, 03:56 PM)josemendez Wrote: Hi,
Changing the phases will have no effect over how collisions are resolved. It is used to simply filter out collisions with certain objects.
Thickness will simply alter the size of the collider.
None of these settings will change how the cloth behaves in any way.
You're using just 3 distance constraint iterations, and 1 solver substep. Try increasing both of them as I suggested in the previous message : 5 iterations, 2 substeps. Doing this will allow the solver to spend more time calculating in order to make the cloth stiffer, so that it will resist heavier loads on top of it. Note that setting the "stiffness" parameter that all constraints have to the maximum will only allow the solver to make them as stiff as possible within the current iteration budget. If the budget is too low, you will have to increase the iteration count to give the solver a chance to reach the desired result.
This is how all game physics engines work, try this experiment in Unity: place a 1000 kg box on top of a 1 kg box, hit play to watch it sink and/or explode. To fix this, go to the physics manager and crank up the amount of solver iterations (the default is 6 which is too low for this scene). See:
https://docs.unity3d.com/Manual/class-Ph...nager.html Just tried doing what you mentioned. Made no difference. Sphere sinks straight through it. Even went up to 4 substeps and 8 distance contraint iterations. Same result. May I send you the project so you can have a look? Nothing I try seems to make a difference here.
Posts: 6,321
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
(10-09-2018, 04:03 PM)arrnav96 Wrote: Just tried doing what you mentioned. Made no difference. Sphere sinks straight through it. Even went up to 4 substeps and 8 distance contraint iterations. Same result. May I send you the project so you can have a look? Nothing I try seems to make a difference here.
Tried it here, works perfectly.
I'll record a video for you.
|