For this assignment, we replicated vfx in a preexisting game. I chose the coffee from the train scene in Wolfenstein The New Order. Initially I was also thinking about the bottles from Half-Life: Alyx, but I chose this because I was thinking of also using it for another project, with a "liquid" that only had a textured surface visible.
Due to time constraints I spent most of my time trying to figure out how I could tilt the plane in reaction to movement and added height offset with sine. I did not add rotation to the texture itself or overshoot on the forces.
The VirtualPlaneCoordinates material function is a default function that well, once plugged into a texture sample projects it onto a fake plane.
Then a mask to hide the plane outside its range. In the original tutorial I followed the liquid and rest of the object were one opaque material (water cooler), but since my coffee cup needed to cull the mug in the front, I just made this a masked material and put the coffee cup itself in its own material.
When I have time I'm going to study back up on math because whew boy I felt woefully unprepared trying to figure out rotations.
Faking the liquid's movement requires calculations based off the previous frame, so I needed to create a blueprint to store these values.
I get the rotation between the previous location and the current actor location, get the vector of that, and vinterp between that and the default up facing vector (0,0,1). I also massively reduce this value to put a cap on how far the liquid can lean in any direction.
As a simple way to fake some extra movement, I also offset the height of the liquid with a sine wave. The strength and speed of the material's sine node is also determined in blueprint. While moving this effect doesn't trigger, but once stopped it'll make bobbing motions.
Since the strength snap activates the moment the player stops/makes less movement than the previous frame, I also have a time offset to ensure the sine period always begins at 0.
Virtual plane tutorial: https://youtu.be/SoNK_hQzELg?si=0EsrwZNp4RJHGpom
Mug: https://fab.com/s/087b5f196cd1
Coffee texture: https://stock.adobe.com/search?k=coffee%2Bmug%2Btop%2Bview&asset_id=286531991
Environment: https://fab.com/s/087b5f196cd1
Very cool bottles to check out: