Create Interactive 2D Water From Scratch (Unity Tutorial)

Опубликовано: 08 Август 2024
на канале: Sasquatch B Studios
5k
292

Show your Support & Get Exclusive Benefits on Patreon (Including Access to this tutorial Source Files + Code) -
Join our Discord Community! -

--
I had......SO much fun working on this project... Despite having to completely scrap my first approach!
We're going to use a mesh we create from scratch and move the vertices in wave patterns when your player (or any Rigidbody object you want) interacts with the water. I was inspired by Ori and the Blind Forest to try this out, and I'm super happy with the end result!
This is...kind of a monster video, I realize. I went overboard. But I wanted to make this as good as I could. So here's what we're going to cover:

- Creating a mesh from scratch
- Custom editor scripts (for buttons and some custom handles to resize the water
- Creating a sprite shader for the mesh (includes and edge line, caustics, distortion, and vertex displacement)
- Wave propogation (ie make waves when your player hits the water's edge)

--
Timestamps:

00:00 - Introduction
00:24 - Explanation of why we're using a mesh
01:51 - Creating the mesh
06:07 - Custom editor (for buttons and handles)
08:56 - Creating the main color and wave lines (shadergraph)
11:33 - Adding caustics for the water (shadergraph)
13:49 - Adding distortion for the water (shadergraph)
16:17 - Setting up the CameraSortingLayerTexture and sorting layers for the distortion
17:57 - Adding constant waves via vertex displacement (shadergraph)
21:11 - Setting up the interactive 2D water functions
26:00 - Setting up the trigger handling for the water

---
free water assets used (moss) :


2D water math breakdown:


---
In need of more Unity Assets? Using our affiliate link is a great way to support us. We get a small cut that helps keep us up and running:

---
Looking for some awesome Gamedev merch? -
---

Link to Download the FREE 2D Asset Pack:



Who We Are-------------------------------------

If you're new to our channel, we're Brandon & Nikki from Sasquatch B Studios. We sold our house to start our game studio, and work full time on building our business and making our game, Samurado.

Don't forget to Subscribe for NEW game dev videos every Monday & Thursday!

Wishlist Samurado!


Follow us on Twitter for regular updates!