High performance water: Swimmable part 2.0

Greetings my fellow developers.

About a year ago I released the first version of this project, and I think it’s time to release the second big version.

What’s changed?

The system has been completely re-written, to remove some problems and re-organise the whole code.
This is one of the most important things I fixed in this version:

The overall mechanics have also improved.

Source

About the system

  • Works for both R6 and R15

  • Works with collection service

  • Works for all platforms (including console)

  • Works with all the shapes that work in zone+

  • Only has the swimming property of roblox’s water. If you want to use it with boats too you will need to make that yourself.

  • Handles low fps a lot better than roblox’s water

  • IMPORTANT: Take into account the system is completely client-side. Meaning it could falsely set off anti-cheat systems in your games or if you don’t have these type of systems it could be abused to do things like flying around. Making a server-side anti-cheat is up to you until I have time to do one myself.

How can you set it up? - with the folder method

  1. Insert the model into StarterCharacterScripts image.

  2. Create a folder in workspace, and insert whichever parts you want the players to be able to swim in inside the folder

  3. Set the value of “PartFolder” to the folder in which you have the parts:

  4. IMPORTANT: Make sure all the parts have “CanCollide” false and “Anchor” true

  5. Go to configuration, and set the values to whatever you want:

    • CharDensity: The speed in which the character will go up when being idle inside the water.
    • CharDensityUp: The same but while the player presses space/buttonA on xbox (this isn’t available on mobile)

How can you set it up? - with the collection service method

  1. Insert the model into StarterCharacterScripts image.

  2. Tag your parts using the collection service default plugin. Use whatever name you want for the tag:

  3. Put the name of the tag you used in the string value:

NOTE: if you didn’t understand this short tutorial of how to set up collection service there are better ones in youtube

How does the player use it?

It’s basically the same as roblox’s water except for one thing. For mobile players, the jump button is disabled because of disabling the jumping humanoid state. So, mobile players, to get out of the water, have to tap on the screen, which will simulate jumping.

How does it work?

It’s honestly pretty simple. Firstly, it has different positions located relative to the character. These determine if the character is inside/outside of the water or floating on the surface. Using zone+ I check which of the detectors are inside to find that out.
To make the character swim I disable all the humanoids states that are prioritized before swimming, and to make the character not affected by gravity I use a vector force, applying as force the character’s mass multiplied by gravity (basic physics)

Showcase

Changelog

  • 26/12/22 - Added the posibility to use collection service for the water parts
  • 11/08/22 - Made it actually work on console
TL; DR

Go read the whole post you lazy duck

Thanks. Any support is appreciated

Skinned mesh water will be compatible with this

142 Likes

Could we get a Github? onlythirtycharacters

3 Likes
2 Likes

Glad to see that you’ve expanded upon this system, and gave it a breath of new life.

I will be sure to try it out, and see if I can encounter any issues with it. Thank you for making a system that I probably would have teared my hair out doing myself.

2 Likes

didn’t knew you’d post the same day but man, I’m so excited to use this!

2 Likes

I looked over it again, it seems it is detecting that I’m entering, the vector force is appearing but my character does not appear to have buoyancy.

2 Likes

Could you send me the custom rig? I have an idea of what could possibly be causing the issue but I would have to test it

1 Like

Hey dude, I found a…bug? When your camera is facing downwards in pc and you hold W and Space at the same time, instead of swimming down quicker, the player swims to the surface. If you put CharDensity above 5 the player will flung into the air out of the water.

1 Like

Also I want to make a 2d section with Water. 2d controlls are easy to make, but with the Water controlls it doesn’t work. On the keyboard W and S should make the player swim up and down and A and D left and right( same with toggle on mobile ) but I have no idea how to do that with your water, any suggestions that could help me?

1 Like

That’s because the velocity applied to the player when pressing space is relative to the world, not to the character

Can you send a video?

Don’t know. Take into account that my swimming mechanics are the same as roblox’s. So if you make a 2D system that works with roblox’s water it will work on my water too.

hmm, I’d just wanted to make it so you only can walk on X/Y axes. Guess I’ll have to dig in deeper to solve this problem

1 Like

robloxapp-20221119-1320531.wmv (833.5 KB)

I had a CharDensity of 7 here

btw that’s my first time posting a video here, can you tell me how to make the video just straight appear? Without downloading it…

Idk, I never record with roblox’s built in record feature, I usually record with gyazo and then embed it here using html

Can you send an rbxm file? Can’t seem to get the same behaviour

DaGpm231’s Water.rbxl (70.4 KB)

Can’t seem to get the problem, how did you do it?

Can you add an event to detect the player is swimming? I really need it to make my oxygen bar

EDIT: Nvm I just need to use :GetState() and .StateChanged :skull:

2 Likes

swim down a little bit with the camera also facing down and while holding W/Toggle, just hold space. Not for 1 second, like the whole time. If the player uses this water for the first time and wants to swim down faster, I assume they will try to press and hold space cuz that’s like Roblox water behaves

Hands down one of the best building resources ever. So helpful!!! Thank you so much!!!

1 Like