• News

• Industries

• Learning & Support

• Community

• Marketplace

# Drink in glass to move around?

Does anyone know how to do this so the liquid reacts to movement?

Do you want the liquid to splash in reaction to something? Do you want the liquid to vibrate like in Jurassic Park when the tyrannosaurus rex is approaching? Or do you want to tilt the cup and have the liquid stay parallel to the ground? The splash could be a particle effect. The vibration could be done with a material instance. Tilting the cup would be more complicated, but I think it wouldn’t be too hard. Tell us more about what exactly you want to do, and I’ll tell you how I would approach it.

yeah you gotta be a bit more specific

I made this not so long ago for potions in my game - Imgur: The magic of the Internet
it’s all shader trickery. the biggest challenge was to have something that would be opaque, since translucency doesn’t receive dynamic lights (so these would “glow” while in the shadows)

I didn’t bother trying to add any inertia/recoil to the liquid since it would never even be visible in the game, and it would be much harder to pull off

Thanks guys, yeah I should have explained better what I’m trying to achieve.

I’m working on a molotov cocktail that the player holds in first person. I’d like to display the fluid inside the bottle, that will slosh around as the player moves. I’m already using APEX clothing for the wick, but would love to show the fluid moving also.

@Chosker What you show there is very much what I’m after, however I’d like it to have physics, so if the player turns left suddenly the fluid would slosh to the right.

I made this material for my potions. It works perfectly with spherical containers, other shapes may have some problems. The idea is simple: find a center of your container, then apply level and slosh offsets to it. Everything above the resulted height will be transparent.
After you recreate this material, adjust CenterOffset to match it with the center of your bottle. PotionLevel controls amount of liquid. 0 value will make it half full.

Physics will be a bit harder to do, but it’s quite achievable with some simple scripting.

](&d=1553419063&type=full)

Thanks for your input @Avatarus I’ll give that a try and see what kind of results i can achieve. Cheers