Obi Official Forum
Soft Body not colliding 2D mesh - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Softbody (https://obi.virtualmethodstudio.com/forum/forum-12.html)
+--- Thread: Soft Body not colliding 2D mesh (/thread-2668.html)



Soft Body not colliding 2D mesh - beatrichartz - 28-12-2020

Hey there,

I freshly bought soft bodies and I do have a problem setting up a 2D project with soft bodies. I've created a planar mesh, generated a blueprint from it, and added the components for it to my 2D world.

Desired behaviour would be for the 2d planar circle mesh to behave like a bouncy ball, i.e. it should staunch on impact, just like the 3D soft balls in your soft ball demo.

I've uploaded my project here.

Currently what it does for me on Unity 2020.2.1f1 is the following:
- With normal unity RigidBody 2D and colliders, everything works smoothly
- When I add in the Obi Resolver, OniColliderworld and Obi Softbody components, frame rate goes down. Also, the collision stops to work, e.g. the ball goes through the floor.
- I've selected mode 2D, however I'm seeing the ball transform in Z position as well, which I think is not supposed to happen

This is probably a misunderstanding from my part since I'm new to this engine. My questions are:
- What am I doing wrong?
- Are there more in depth Obi 2D tutorials available?

Thanks


RE: Soft Body not colliding 2D mesh - josemendez - 28-12-2020

(28-12-2020, 09:47 AM)beatrichartz Wrote: Currently what it does for me on Unity 2020.2.1f1 is the following:
- With normal unity RigidBody 2D and colliders, everything works smoothly
- When I add in the Obi Resolver, OniColliderworld and Obi Softbody components, frame rate goes down. Also, the collision stops to work, e.g. the ball goes through the floor.
- I've selected mode 2D, however I'm seeing the ball transform in Z position as well, which I think is not supposed to happen
Thanks

There's a lot of issues with your scene:

- Your floor doesn't need to be a rigidbody if it isn't moving around due to forces/interaction with other objects. If you need it to be for some reason, set it to Kinematic instead of Static. The main performance issue right now is a warning message being spammed to your console, telling you to do this:

Quote:"Cannot use 'velocity' on a static body."

Changing to kinematic stops the console being spammed and the scene runs at +500 fps.

-The floor you're using is extremely thin. This will cause tunneling issues unless the objects colliding against it are really large. The rigidbody sphere is quite large, but the softbody particles are considerably smaller. Just making your floor thicker should fix collisions. For more info on tunneling (which is quite common in all physics engines) see: https://www.youtube.com/watch?v=ms0Z35GY6pk

- You've added a rigidbody component and a collider component to your softbody. This doesn't make any sense. An object can be either a softbody or a rigidbody, not both at once. This will also kill performance because the softbody particles are trying to collide with the collider in a loop, with no hopes of being able to actually resolve the collision. Remove the ObiCollider, ObiRigidbody, CircleCollider2D and Rigidbody2D components from your Circle GameObject. Particle dynamics/collision detection can handle things fine on their own.

- You've not added a ObiSoftbodySkinner component to your softbody, and you're using a MeshRenderer instead of a SkinnedMeshRenderer. This will result in no visible deformation being applied to your mesh. Softbody rendering works by linear-blend skinning your mesh to the underlying particle-based representation of your softbody, just like character deformation works. So for the mesh to deform at all you need to bind it to the softbody simulation. See: http://obi.virtualmethodstudio.com/tutorials/softbodyskinner.html

- The anisotropy neighborhood value in your blueprint is way too large for the size of your mesh. Set it to zero and click Generate to refresh your blueprint.

With these adjustments, here's the result:


(28-12-2020, 09:47 AM)beatrichartz Wrote: - Are there more in depth Obi 2D tutorials available?

2D is exactly the same as 3D, just one dimension less Sonrisa. All existing documentation is directly applicable to both 2D and 3D. Let me know if you need further help with it. cheers!


RE: Soft Body not colliding 2D mesh - beatrichartz - 29-12-2020

Thanks, corrected all of that and now it's almost working as expected.

Just one last question, how did you get the rig setup for the mesh to transform together with the particles? It seems no matter what bone structure I'm setting up, the mesh just does not transform according to the particle transforms.

(29-12-2020, 01:06 AM)beatrichartz Wrote: Thanks, corrected all of that and now it's almost working as expected.

Just one last question, how did you get the rig setup for the mesh to transform together with the particles? It seems no matter what bone structure I'm setting up, the mesh just does not transform according to the particle transforms.

Classic pebkac forgot the skinner Sonrisa Happy new year!


RE: Soft Body not colliding 2D mesh - josemendez - 29-12-2020

No worries, glad you got it working! Happy new year Sonrisa


RE: Soft Body not colliding 2D mesh - all2i - 05-04-2021

(29-12-2020, 12:39 PM)josemendez Wrote: No worries, glad you got it working! Happy new year Sonrisa

one more thing , how to freeze any other axis?

when changing Mode from 3d to 2d it freezes the Z axis. what if I want to freeze other axis is it possible?

unity rigid body can do it easily but how in ur rigid body?


RE: Soft Body not colliding 2D mesh - josemendez - 05-04-2021

(05-04-2021, 12:07 PM)all2i Wrote: when changing Mode from 3d to 2d it freezes the Z axis. what if I want to freeze other axis is it possible?

This doesn't freeze a rotation axis for a softbody, this performs the entire simulation in 2D. Affects both positions and rotations of all particles from all actors in the solver, it is a solver-wide change.

(05-04-2021, 12:07 PM)all2i Wrote: unity rigid body can do it easily but how in ur rigid body?

You can't freeze the rotation axis of a softbody, simply because there isn't a *single* rotation axis for the entire softbody (unlike there is for a rigidbody, for obvious reasons). Individual particles of the softbody can freely rotate around their own axis each.

So you can only restrict rotation on a per-particle basis. Using the particle API you can get the rotation quaternions of each particle, project them to a certain axis, then write them back. See: http://obi.virtualmethodstudio.com/tutorials/scriptingparticles.html