Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Collision & Stickiness to Moving objects
#1
Hi,

We just got Obi Fluid for our little project because it just looked awesome (and it is!)

I've taken the FluidViscosity scene and the Obi items within it, and repurposed them in my scene with some adjustments and it looks great...but now I'm wondering how I can, or if, the obi particles/fluid will stick on a moving object - they just slide off right now even with all the stickiness parameters increased. 

- The example attached is just me moving the (grey) object that the particles land on. 
- The Collision Material has a Friction of 1, Stickiness of 1, Stick Distance of 0.2
- The Emitter Material has a Smoothing of 1, Viscosity of 2, Surface Tension of 2
- The Solver is default from the Sample Scene (I think), Collision Constraint is Enabled, Stitch Constraint is Enabled, Density Constraint is Enabled
Reply
#2
(03-02-2018, 08:09 AM)Markles Wrote: Hi,

We just got Obi Fluid for our little project because it just looked awesome (and it is!)

I've taken the FluidViscosity scene and the Obi items within it, and repurposed them in my scene with some adjustments and it looks great...but now I'm wondering how I can, or if, the obi particles/fluid will stick on a moving object - they just slide off right now even with all the stickiness parameters increased. 

- The example attached is just me moving the (grey) object that the particles land on. 
- The Collision Material has a Friction of 1, Stickiness of 1, Stick Distance of 0.2
- The Emitter Material has a Smoothing of 1, Viscosity of 2, Surface Tension of 2
- The Solver is default from the Sample Scene (I think), Collision Constraint is Enabled, Stitch Constraint is Enabled, Density Constraint is Enabled

Hi there,

There's a fundamental misunderstanding of physics/game engines here, the same as in this (somewhat related) post:
http://obi.virtualmethodstudio.com/forum...hp?tid=283

Changing the transform of an object does not "move" it. It "teleports" the object from one frame to the next, without altering its velocity (linear or angular) so the physics engine will not acknowledge this displacement.

The fluid particles relate to the surface they are stuck to via friction. Friction is a velocity-based effect, when a object moves relative to the particles only part of its velocity is transferred to them. However if you change the transform from frame to frame, the object's velocity will stay zero, thus no velocity will be added to the particles and they will stay where they are in world space.

The same effect can observed in all physics engines. In Unity for instance, try placing a cube on top of a kinematic one, then transform the bottom one: intuition would say that the one at the top would move with it, but it won't.

The solution is to either move your object using forces (you'll need it to be a rigidbody, so that it also takes part in the simulation), or to derive (differentiate)  velocity values yourself.
Reply
#3
(03-02-2018, 08:09 AM)Markles Wrote: Hi,

We just got Obi Fluid for our little project because it just looked awesome (and it is!)

I've taken the FluidViscosity scene and the Obi items within it, and repurposed them in my scene with some adjustments and it looks great...but now I'm wondering how I can, or if, the obi particles/fluid will stick on a moving object - they just slide off right now even with all the stickiness parameters increased. 

- The example attached is just me moving the (grey) object that the particles land on. 
- The Collision Material has a Friction of 1, Stickiness of 1, Stick Distance of 0.2
- The Emitter Material has a Smoothing of 1, Viscosity of 2, Surface Tension of 2
- The Solver is default from the Sample Scene (I think), Collision Constraint is Enabled, Stitch Constraint is Enabled, Density Constraint is Enabled

Here, I wrote a small helper script that calculates linear and angular velocities for a kinematic rigidbody. This way you can move your object around using its transform, and still have it update its velocity.

Just add it to your collider, make sure that it has a kinematic rigidbody component too.

Code:
using UnityEngine;

[RequireComponent(typeof(Rigidbody))]
public class ObiKinematicVelocities : MonoBehaviour {

    private Quaternion prevRotation;
    private Vector3 prevPosition;
    private Rigidbody rigidbody;

    void Awake(){
        rigidbody = GetComponent<Rigidbody>();
        prevPosition = transform.position;
        prevRotation = transform.rotation;
    }

    void LateUpdate(){

        if (rigidbody.isKinematic)
        {
            // differentiate positions to obtain linear velocity:
            rigidbody.velocity = (transform.position - prevPosition) / Time.deltaTime;

            // differentiate rotations to obtain angular velocity:
            Quaternion delta = transform.rotation * Quaternion.Inverse(prevRotation);
            rigidbody.angularVelocity = new Vector3(delta.x,delta.y,delta.z) * 2.0f / Time.deltaTime;
        }

        prevPosition = transform.position;
        prevRotation = transform.rotation;

    }
}
Reply