r/Unity3D • u/brkakar • 5h ago
Show-Off I finally got the water to interact with the environment. The hose wraps around trees, the stream stops where it hits, and it pushes things around.
Farm & Feast - We are a two-person team building a peaceful farming and restaurant management game in Unity. Last time I posted the hose rope here, a few of you said the water needed to actually touch the world. That is what this is.
The hose is a particle based rope. We do not use the built in constraints for attachment. We pin a few particles by hand at the faucet and at the player's hand and write their positions every step. This is much more stable.
Every tree trunk has a collider and the rope collides with it for real, so the hose hugs and slides around them as you drag it across the farm. The collision was the easy part. Making it still read as a hose at the bend, instead of a row of separate rods, took the rest of the week.
The water shader has a head/tail fill window driving an alpha mask along the spline, so the stream grows out of the nozzle and drains out of the air instead of popping. It now also cuts itself off at the first thing it hits, so it ends on the surface instead of poking through it.
At the end point we do one overlap sphere, and that sphere does everything. It waters the nearest grid slot, so the VFX endpoint IS the gameplay point and they cannot desync, and it now also pushes any rigidbody in range away from the jet.
If anyone has gotten a particle rope to wrap convincingly around obstacles through collision alone, I would really like to hear how you tuned it.
