Intro: Expanding Movement Into Water Most third-person controllers stop at ground movement. But what happens when the player hits water? Without a proper swimming and diving system, games feel limited and immersion breaks. The Modular Third-Person Framework includes a complete water system with swimming and diving mechanics powered by smooth state transitions, buoyancy, ScriptableObject-driven configs, and a dedicated Breath system for diving.
The Challenge: Water Mechanics in Unity Developers usually face big hurdles when adding swimming and diving:
- Player abruptly snaps between states (walking → swimming).
- No control over buoyancy or surface alignment.
- Diving feels disconnected from surface swimming.
- Breath systems are often hacked in separately and don’t integrate with the controller.
- Debugging becomes messy with overlapping swim/dive/locomotion states.
The Solution: Swimming & Diving in the Framework The system is designed to give players freedom and realism, while keeping it modular for developers. Key Features
- Enter/Exit Swim States → smooth transitions when entering/leaving water volumes.
- Swim State → surface movement with stamina costs and buoyancy to keep players aligned at the water surface.
- Enter/Exit Dive States → seamless transitions from swimming to diving and back.
- Dive State → full 3D underwater movement with configurable thresholds and multipliers.
- Breath System Integration → diving tied to a standalone Breath system with UI bar, ScriptableObjects, and player-side implementation.
- Stamina & Oxygen Management → swimming drains stamina, diving consumes oxygen, and extended oxygen loss triggers health penalties.
- Multiple Exit Types → walk out of shallow water, grab a ledge, or climb ladders directly from water.
- Water Volume Detection → WaterVolume scripts attached to scene water objects automatically trigger transitions.
- ScriptableObjects → configure swim speed, buoyancy, dive depth, stamina cost, breath duration, and exit forces.
Proof: Immersion in Action Without the framework:
- Player snaps awkwardly when touching water.
- Swimming looks like flying through air.
- Diving has no breath control or disconnects from swimming.
With the framework:
- Player runs → enters water → transitions to Swim state smoothly.
- Buoyancy keeps body aligned with the surface; head height adjusts naturally.
- Press dive key → player transitions into Dive state with full 3D control.
- Breath bar depletes while underwater; running out drains health.
- Exiting → player can walk out, climb a ledge, or use a ladder seamlessly.
Developer-Friendly by Design The Swimming & Diving system is built for flexibility and extensibility:
- Interface-driven → water objects only need a WaterVolume script.
- Grace Mechanism → smooth blending across Swim/Dive/Locomotion states.
- Factory Pattern → swim and dive states created/managed by the state factory.
- Events & Delegates → transitions can trigger splash audio, underwater effects, or breath UI updates.
- ScriptableObjects → configure all swim/dive data in the Inspector without touching code.
- Debug Toggles → logs for buoyancy, stamina, breath, and transitions can be enabled per state for testing.
Use Cases
- Adventure games → explore environments with swimming and diving.
- Survival games → manage stamina and breath for resource gathering.
- Stealth games → sneak underwater to evade enemies.
- AI consistency → extend water mechanics to NPCs and enemies.
Seamless Water Gameplay Swimming and diving are often ignored or hacked into third-person controllers — but in the Modular Third-Person Framework, they’re fully integrated with the same state-driven, modular design as every other mechanic. Players enjoy smooth transitions and immersive gameplay. Developers get modular, configurable systems that just work.
👉 Get the Modular Third-Person Framework on the Unity Asset Store: Modular Third-Person Framework | Game Toolkits | Unity Asset Store