Animated fluid inside a ball

I wanted to know if it is possible to create a hollow (transparent) sphere in a 3D Modelling program and have fluid animated inside of it. So depending on how the sphere moves, the fluid inside reacts to the sphere’s movement. I then wondered if it were possible to import said sphere with the animated fluid inside of it, and import it into Unreal Engine 4.

I would like to know if doing this is possible, as I intend on making a ball with liquid inside of it a playable character model using the Rolling Ball Blueprint.

In short: Is there a way to import a ball with moving animated fluid inside of it into UE4?

Any advice would be helpful.

In short yes, but this means the fluid will be pre-baked and will move exactly the same way at a given time for that motion. It wont blend from mode to mode either, so you wont have smooth animation blending from one fluid form to another, say ball rolling and stops.

Use alembic mesh sequence.

You could probably animate that kind of effect with a few morph targets as far as the fluid having a reactive wave motion and rotate the mesh the right direction to react to motion.You could also control the intensity based on how fast it’s moving.

I’m not too familiar with this. Do you know of some video that shows this kind of effect?

Hrm, well that is a problem. If that can’t be done, I suppose I could go ahead and try put many small balls with physics inside of a hollow ball and see how that affects performance. Thanks for your reply either way, much appreciated.

That’s not going to work to your favor, and even if it does it will never be reliable as physics tends to intersect and penetrate and having many small balls in a confined moving space is like worst case scenario for the engine.

I think your best bet is morph targets and cleverly made fluid blend shapes (as Darthviper suggested), then blend between those to simulate the effect of fluid in a ball. It wont be perfect but if it’s a stylized look then it may work better.

I don’t think you can get a better option than this with what the engine can offer you out of the box.

Actually, you might not need morph targets, I’d just set up some kind of dynamic animation rotating the water mesh, so it would angle a bit as you move forward and then when you stop it just rocks back and forth based on the force of stopping. It won’t have things like splashes, and if you wanted to make it look more “wavy” then you could add that with morph targets, but you don’t need to do too much I think. Since it’s a sphere it doesn’t need anything crazy. If it were a different shape like a cylinder or a box then you’d definitely need morph targets, but a sphere you could just rotate it.

Ah, now that I imagine would be possible, I was just thinking of how I would do it, but yes I have a feeling this is the best way of doing it.

I’m assuming this is similar as to what Valve did with Team Fortress 2 with the liquid in bottles such as in this video here https://youtu.be/AOeP57bpHa8?t=193 I’ve time-stamped it so it’ll show the liquid movement I’m talking about.

I don’t suppose you would know of a walk through that teaches you how to do this, do you?

I would suggest to you to follow this video from Ryan Brucks (from Epic) where you can mix the idea of filling the ball with small balls and using distance fields to merge the ones inside. With some material tweaks you could simulate movement from them (as they are merged) which will mimic at some point the water effect. I know this is like a hack solution, but it has great performance, so the number of balls inside could be dozens, and I think that with just physics responding to the movement you will likely to have a liquid motion since they are merged by the technique he explains. Let me know your findings!

[quote=“, post:9, topic:105530”]

I would suggest to you to follow this video from Ryan Brucks (from Epic) where you can mix the idea of filling the ball with small balls and using distance fields to merge the ones inside. With some material tweaks you could simulate movement from them (as they are merged) which will mimic at some point the water effect. I know this is like a hack solution, but it has great performance, so the number of balls inside could be dozens, and I think that with just physics responding to the movement you will likely to have a liquid motion since they are merged by the technique he explains. Let me know your findings!

Through watching that video I found that it didn’t really explain how to make a Metaball, but rather what you can do with them. I’m not too well versed in material editing, but this does seem like a method of achieving what I’d like. The only problem is I’m not sure how to make a Metaball, and from researching about them I found that you can buy a pack of Metaballs for around £15 but I’m not sure about buying the asset pack just yet as I’m concerned I may not be able to put them inside of the balls in my game.

the core of the technique is to make smart use of distance fields. That video just don’t explain how to make the transparent material, but teaches how to make each sphere melt into each other, which is key for what you want. The asset at the store I can’t tell if is based on the same concept, even more seeing the comment section inside it Im afraid. I think you could ask @RyanB if there is something else needed, if he has some spare time he might just sent few words here.

Depending on the size of the sphere and how far it’s going to be from the camera, the distance field may not have enough resolution and at best the spheres would look like they are filled with hot play doh. The idea of having a fluid mesh rotating counter to the sphere’s movement sounds like it could produce more controllable results. More aggressive splashing effects could be done using actual animations or even vertex animations using Alembic.

Which platforms you plan on running your solution?

Just PC for now.