Fill a tub with water, let inside object raised by the water and let float

Hi there,

In Blender v 2.90.0, for an animation scene, I am throwing an object into a tub with both having rigid body modifiers on. The object is set to “active”, the tub is set to “passive”.
First the object was dancing around like crazy. I assume it has to do with collision detection. I played around a bit with collision margins but could not find any proper values. Object and tub have quite a similar size. Maybe that is the problem.
Anyway, I then keyframed the animation of the object so is stays still after it fell into the tub. So far, so good.

Now comes the “problem part”. I then fill the tub with water and want the already inside object getting raised by the water so that it floates.
Pouring water into the tub is no problem, but the object jumps around again and passes through the mesh of the tub a bit.

At this stage Physics settings for tub and object are:

Any have a solution for that? Maybe I am thinking too easy and I have to “connect” the object to the fluid in some way?

The very last thing I would do, is to animate the location and rotation of the object as water comes in. But that would not be that nice.

Yeah, I’d say, connect the object to the fluid in some way.

You can create a rigid body constraint to create spring action between your object and some other (non-rendering) object (with rigid body + animated) that can be shrinkwrapped to the surface of the water. That will cause the rising water to drag the invisible object, which will drag the rendering object up with it, without giving up physics-- it’ll still have inertia and bob a bit in the water.

There are plenty of conceivable issues with doing this, which should be solvable with some more layers of indirection, but I won’t get into them because they may not even be an issue for you.

Your best bet for getting good rigid body collision is to use as few mesh collision objects as possible. For the floater, can you use sphere collision? For the bathtub, can you make a few non-rendering, passive RGB walls with box collision? Primitive collision is the most reliable.

Hi, thank you very much. This sounds very promising but I struggle with your first mentioned part

You can create a rigid body constraint to create spring action between your object and some other (non-rendering) object (with rigid body + animated) that can be shrinkwrapped to the surface of the water.

Should the floating object be shrinkwrapped to the water domain for target? I am pretty unsure with the settings of the Shrinkwrap constraint, played around a bit but object is not moving when the water comes in.

Could go a bit more into detail how to apply this constraint?

Take a look at this…

Yes, shrinkwrapping to the domain is working for me:

Here, I have it on project mode, so that it will only ever shrinkwrap to the top (from its position at world origin).

I imagine that some of the details depend on the exact fluid settings-- for example, it won’t work unless your fluid has actual geometry. The fluid I made here is just quick liquid, edited only to enable “mesh”. I’m not very experienced with fluid simulations, just enough to do something quick like this.

I already watched this before, but this is not working for me. The big difference is, that the guy in the video already has water generated. So the water has actually mesh where he can connect the shrinkwarp to.

Myself does not have water at the beginning. It is an empty tub with an object inside. Water raises and then should take the object with it. The domain does not provide any mesh to snap on.

I think, I will leave this as is for now and keyframe location and rotation to kind of emulated floating. Seems to be a not so easy animation-relationship.


EDIT: There just came some interesting thoughts in my mind, while having dinner :slight_smile:
Will provide them tomorrow if I have tried them out.

I found a solution which is quite reasonably working. It is a combination of let an object float on an ocean simulation (like described in the video above) and copying the rotation of the object floats on the ocean to the actual floater in my scene for emulating the wavelike movement. I go more into detail now:

Below my actual scene, meaning out of vision of the scene, I did the following:

  • create a plane and add ocean modifier
  • in the ocean settings set the size to 0.25 as I only need a small ocean
  • set wave scale to 0.125 as I only need a small wave movement
  • set one keyframe for the „Time“ value of the ocean
  • in graph editor add modifier => „generator“ to the „Time“ value
  • set X value to 0.05 for slower wave movement => ocean is now animated

  • create a small plane which is slightly bigger than the floater you want to control
  • add reasonable amount of subdivisions to the plane so it can better transform to the waves movement
  • add shrinkwrap modifier (not shrinkwrap constraint) to the small plane and choose ocean for target
  • in Edit mode, choose all faces and add them to a vertex group

  • To the original floater, add „copy rotation constraint“ with target the small plane which is already shrinkwrapped to the ocean and for „Vertex Group“ choose the beforehand created vertex group
  • Once in my scene the water starts filling the tub, I keyframe the location of my original floater so that it moves up with the raising water
  • additionally, I keyframe the „Influence“ of the „copy rotation constraint“ so that the floater gets calm after some time when no more water is filling the tub

I made some screenshots of relevant values to make it more clear. I hope this will help other people, too.

Very intersting what you need to do, just to make it work. Would be nice if fluid could cause buoyancy by default and take weight and mass density of objects into account. For example, a selectable option for a „Fluid - Type: Effector“ => „enable buoyancy“ would be nice.

Maybe that option comes in the future.

Well, although this above mentioned workaround kind of worked, it was not so nice at the end and still bugs me. I now experimented with

  • shrinkwrap a plane to the fluid domain
  • copy location constraint (target: plane) on the floating object

The floating objects gets thrown into the tub, so it has to have rigid body collision enabled.

After that, it should be getting raised by the incoming fluid. That works so far.

But when the copy location constraint reaches it’s influence value of 1, the floating object jumps onto the plane. But I want a smooth transition to make it look realistic.

I would be very thankful if anybody has some hints for me how to fix that.

Blender file attached.

fluid1.blend (1.3 MB)

You could bake the rigid body physics to keyframes so that you can disable physics on it and slowly copy location (keyframe influence 0->1 over multiple frames) if it’s okay with you that it moves.

Otherwise, you have to decide, do you want this to be under the control of the animation system, including constraints, or under he control of the physics system? It can’t be both. It can’t be halfway.

If you’ve forgotten, read what I wrote earlier here:

Emphasis added. If you want a RB to remain under the control of the physics system, yet you want to affect it, then use a different RB, under the control of the animation system .

Thanks for your reply. I definitely want the floating object under the control of the animation system as physics is not important after the object got dropped into the tub and got caught by the fluid.

Slowly copying location (keyframe influence 0->1 over multiple frames) works quite OK for me.

A “different RB”, or “another RB” ?

A different RB would have to be another RB to my mind-- it can’t be different from itself, right? In order to use a RB constraint, you need to have 2 RBs. However, one of those RBs can be animated and the other can be under the control of the physics system.

Gotcha !

Wasn’t sure if you meant “replace your RB” with a different one…

or, “add” a different RB.

As usual, Thanks !