Swimmable part. High performance water

This has been deprecated in favor of the new version, go check that one out

Old one

A complete rewrite is planned for this system (including better swimming physics and skinned mesh water)

Hello devforum, I have seen many people ask how to make a swimmable part, so here you have it. Spanish version.

If you want to support this proyect you can donate here, in the gamepasses section. Anything helps!

SwimmablePart - Roblox

Try it out here:

water - Roblox

Why use this instead of roblox’s terrain water

-It is a lot more performant than terrain water.

-It is a lot more customizable. There are some parameters you can modify to fit better your experience, and if you are a scripter, you can customize it even more.

How to use it:

-There will be a local script called water part. Place that in starterCharcterScripts. In this file I use a water part made by @EtiTheSpirit which has an animated texture.

-It is really simple to configure. With this plugin, you make a tag called the same as this value of this property of the script: image and then mark all the parts you want to be able to swim in with the plugin.

-There are 3 other configurations. I don’t recommend to modify anything inside the script.
—First you got this. image . It is the speed the character will go up when being idle inside the water.
—Second you have this other property. image . It is the speed the character will go up when pressing spacebar/touching the right lower part of the screen on mobile/buttonA in xbox.
—Lastly the swim speed, pretty self-explainatory.

-Remember the parts you use have to be can collide false.

About it

-IMPORTANT NOTE: There is currently a bug with tools. I’m not sure if I will be able to fix that tho, since the bug report team ignored me.

-Works with both rig types.

-It works for all platforms.

-If you want the detection to work well, only use it with square shapes that are not rotated.
Showcase

-Here’s a couple videos about it:

Updates

–Made it so the water parts are the ones you tag in collection service. Works with r6 and r15 7/7/2021.
–Added attributes and ability to go up using jump input.
–Added swim speed attribute. 9/7/2021
–Changed some things in the script to make it a lot shorter and fixed this bug

–Fixed this bug:

–Changed the detection system. 25/8/21. Now lets you accurately detect water shapes while using squares(i.e. holes inside the water, for example a cave)

189 Likes

To get jump input across all platforms you could use UserInputService | Roblox Creator Documentation.

5 Likes

Can it be done with something like a keycode? Since I have the jumping state turned off.

1 Like

Sure, you could just use Enum.KeyCode.ButtonA for the A button on the controller.

Additionally, it might be a good idea to look into ContextActionService considering you’re using the same input action across different platforms.
https://developer.roblox.com/en-us/api-reference/class/ContextActionService

4 Likes

This looks really nice! I’m not at my computer right now so I can’t see the test file, but does this use mesh deformation waves? If not, that would make it 2000% better, if it already uses mesh deformation, I will definitely try it out in my current project!

1 Like

No, it doesn’t use mesh deformation, it uses an animated texture, but I was actually planning to work on that after publishing the code.

1 Like

In that case, this resource may help you:

I wish you luck!

8 Likes

This is very useful! I’ll be sure to check out the scripts to learn the logic of it!

if crazyblox sees this you’re dead lol

1 Like

This is really nice! Thanks :DD

Why woould that be :eyes:

2 Likes

Just a small suggestion, you should make an automatic script to do this using CollectionService. That way, users could just use the Tag Editor plugin and tag parts as water, and not have to go in and edit a script.

1 Like

To elaborate, you could have a variable that stores a string, which would be the CollectionService tag. It could be set to something like “WaterPart” by default, but having it as a variable would allow developers to change the tag easily from the top of the script, in case the name of the tag is already in use in their game.

1 Like

Not sure if this is 100% possible or not, but if it’s possible can you make it so the player will rise faster when holding down space/jump like the actual roblox water? I find myself (and others) having a bit of issues getting out of the water because we have to swim up to get out when it would be a ton better if you can just hold a button on your keyboard or screen.

Issue example: 04620c36fc31962d9ecfcad2078dffda

Sorry if it’s difficult to notice, but it’s pretty easy to notice when you play yourself.

5 Likes

Just added that plus properties you can modify for the speed of it. I had to replace and write lots of lines of code so there will probably be some bugs. If you find any please report them here.

3 Likes

Just an extra side note, uploading this as a model and updating the model when you update the script would be much more convenient if a developer wants to get the latest update of this script. It will be a lot less tedious in the long run.

I will let you know if I find bugs.

2 Likes

this is really cool and useful! I’ll definitely look inside the script to see how you did it (since I’ve also been trying to making a water part, but failed in every way trying). Also with this, literally anyone can recreate flood escape 2 now lol

1 Like

Hey, just figured something out, I wanted to let you know about it, @gpm231 .

When the player enters the water, any previous Atmosphere or Sky effect will be deleted. This could be an issue if someone made a world with a specific skybox or atmosphere had a more “orange” atmosphere. When the player leaves the water, these effects are deleted, and there won’t be an atmosphere effect or skybox in the Lighting section of the game anymore.

Might want to look into how to stop this correctly. Maybe make it so it will create a folder in ReplicatedStorage locally, and will move the old Atmosphere + Sky into the Folder when they enter the water, and then move it back to the sky, deleting the water atmosphere + sky afterwards.

Thanks again for the nice script. No other issues so far!

3 Likes

Will this work on a round-based game? I tried making a map with swimmable water but once the round ends, the water left in the workspace (the map have been removed but the water, not)

1 Like

until this problem is solved, I would suggest teleporting the water somewhere secretive in the map whenever the round ends. You can also choose to change the size of the water when the round ends, but that’s up to you

2 Likes

Just fixed this and updated the free model.

2 Likes

It will work, it isn’t like roblox’s smooth terrain (I think that is what you are trying to say since smooth terrain doesn’t get deleted the same way parts do).

3 Likes