Swimming with the Water System

Hi, oh knowledgeable ones…

I’ll DIVE right in (made this joke already on Discord, asking the same question… but it’s not just old, it’s also bad, so who cares):
I want my character to swim in the water provided by the UE Water System Plugin. Apparently, you need a physics volume set as “water volume” in order to do that, but the water bodies are not, by default, physics volumes.

So I want to know… is there a way to use these bodies of water as water physics volumes with the character?
Placing additional physics volumes where the water is seems like a lot of work (especially considering rivers with splines) and they don’t consider the waves at all anyway.

Another solution might be to react to collision events from the character, but then I need to write logic for buoyancy and surface detection, in addition to the movement logic.

So… what do I do?

Thanks in advance and happy coding.

Hey there @Son_Akira! I actually ended up noticing this as well. The water system came with a custom collision and a special post process volume, so I would have expected that the water volume would have been as well, but upon closer inspection it doesn’t look like it has been integrated! So there’s a number of ways to deal with this.

One would be manually placing the physics volumes, which as you noted could be tedious if you have lots of water.

Second, you could write a BP that does the math between all the splines (for lakes at least) and takes the depth and makes a custom physics box for it automatically. This would be tedious at first, and prone to error for special volumes, but could cut down dev time if you do it a ton.

Third and my favorite: Create a custom movement style and just use the collision that comes with the water system by default. This way you don’t need the physics volumes and can customize how it handles in case you need some special water movement. Best thing about it is if you set it up well, it’ll just work right out of the box! I made a little version of it really quickly just to show what I mean.


Hope this helps!

1 Like

Hi, @SupportiveEntity, thanks for the reply.

I’ve tried just implementing what you showed in your third solution, but it doesn’t work… the character just goes back to walking mode instantly, there’s no buoyancy or friction… I guess what you meant by “create a custom movement style” was to actually implement a movement mode, but I really wanted to take advantage of the built-in swimming movement mode. Looking at the code I saw it actually takes a lot of information from the physics volume, so I can either modify the PhysSwimming() function to work without the physics volume (but I would need to code all the information gathering like depth, surface position and normal - remember the waves - and so on and so forth) or go back to the “place all the physics volumes by hand solution”, but that’s not only tiresome, it also ignores the waves (the ■■■■ WAVES!).

You’re right, I had to set up a custom movement mode which is basically just flying but only works under water. Lacks much of the good stuff like buoyancy. Yeah for the moment until there comes some reintegration to the old swimming system it’s likely best to run a custom movement. That said I wonder how hard it would be to take the volume information from the post processing volume that’s used (that works with the waves) and toss it into a physics volume? Likely not the easiest modification, but I haven’t looked at the source for the water system myself to verify that.

@SupportiveEntity Have you some news about the best method for swimming in water body ?

Hey there @Snowbeat! I’d recommend starting simple like this tutorial shows off, and then expanding the movement mode as you see fit.

Disclaimer: One or more of these links are unaffiliated with Epic Games. Epic Games is not liable for anything that may occur outside of this Unreal Engine domain. Please exercise your best judgment when following links outside of the forums.

I did much more unfortunately i can’t block the character to fly out of water when swim up :sweat_smile: its possible use buoncy component for limit the character to the surface of water ?

I wouldn’t explicitly use the buoyancy component because it’s not going to work with the character controller running at once. I’d more likely have some custom logic more akin to how games handle climbing and clambering, where there’s a collision or checks that occur when you’re in that movement mode. For example, swimming as a player, your collision or check would be that the player has their head or their effective upper body out of the water, and if so take jump inputs to swap movement mode and launch them.

1 Like