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.
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?
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
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 (notshrinkwrap 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.
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.
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 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.