-
Notifications
You must be signed in to change notification settings - Fork 1
Liquids
Johnathon Leon Guerrero edited this page Jan 29, 2022
·
2 revisions
Anything that holds liquid that can be poured by the player, filled by the player, or emptied by the player should follow these steps:
- Add the 'LiquidContainer' component if any of the above criteria is met. This allows you to set the total capacity (mL) of the container as well as the starting amount of liquid in it (current volume)
- If the starting amount of liquid is > 0, add a liquid material to the above component
If the object should be fillable by the player
- Check the 'isFillable' boolean in the 'LiquidContainer' component
- Create a child mesh (usually a cylinder or cube) that will represent the liquid object. Make it pretty thin so that when it's at the bottom of the container, it doesn't poke out
- When the liquid mesh is at the bottom of the container (still visible from the inside but not visible from the outside), create an empty child for the mesh then drag it out so it is a child of the container instead (this will copy the position values from the mesh) and name it 'start'
- Now raise the liquid mesh so that it's at the 'full' level of the container, create an empty child for it, then drag it out and name it 'end'
- Use the 3 recently created game objects to populate the remaining fields in the 'LiquidContainer' component.
If the object should be pourable by the player
- Check the 'isPourable' boolean in the 'LiquidContainer' component
- Make an empty child and move it to the spout location of the object then add it to the 'spout' field
- Add the 'Stream' prefab from 'GamePrefabs' for the 'Stream prefab' field
- Check the 'Variable Pour Rate' if this object should increase pouring volume when it is tipped over more (good for objects with open tops like a bucket, not for narrow openings like an oil bottle)
- Modify the 'Pour rate multiplier' if necessary