High performance water: Swimmable part 2.0

Oh, I thought it was written like that on my script. I’ll change it. Thanks

2 Likes

Is there a way to let it work with mesh water that is client-side (duplicated from replicated storage to workspace on client-side)?
I have tried using tags and other ways but nothing worked.

The whole system is client sided meaning it should technically work

But it doesnt no matter what i did, but after having a good sleep ill try again

Thanks for the resource and tutorial!

Unfortunately, something prevents my character model from swimming - up, down, left or right. The jump mechanism is the only feature that works.

Here is an image of my character. Despite its unconventional design, it is fully rigged and is compatible with Roblox.

Here is a video of the issue:

What would be the issue here? I’ve tried changing CharDensity and CharDensityUp, but the problem hasn’t been fixed.

(Ignore the first person setting - I’ve toggled it on and off, and there’s been no change to the issue)

Are you sure its well optimized? I’m not sure if this is a problem on my end but I have a ocean with a ocean floor, and I added some terrain to the bottom of the ocean floor, along with some meshes like seaweed and kelp to make it more lively. As soon as the player jumps in the water, I get like 3 fps, and my screen shakes extremely. I have 110 seaweed meshes and 100 kelp meshes. I know thats alot, but my PC shouldn’t be getting 3 fps when it tries rendering that. The meshes are very low poly, and have no textures, and I know its not the meshes fault because I made the seaweed and kelp meshes above the water and roblox had no problem rendering those. I also have about 30 grass meshes above the ocean on my water, and they have no issue rendering. To test, I removed the kelp meshes and reduced the amount of seaweed to 30 meshes, and made them the same texture. I still went from like 120 fps outside the water and like 10 inside the water. If you want to test this out yourself just make a big water part and add like 50 meshes deep inside of the part, and also, the reason for it being laggy isnt related to the underwater lighting, because I disabled that too and it made no difference.

Video of the issue

So it seems that the issue was on my part, because my water was 2048 x 2048, which was too much for the game to handle I guess. Sadly, you can’t make large oceans using this water system, but making my water 1024 x 1024 made it way smoother.

Hi are you able to share the float update?

Hi, I released a module to make your parts float in this water: Simple Floating Module

1 Like

If there are lag issues it’s probably related to the zone+ module I use to detect contact witht the water. Unfortunately I can’t do anything about that.

1 Like

hello, is it possible to make custom swimming animations for r6 with this script?

No, but you can make your own by checking if the humanoid state is swimming and then applying the animation.

Doing this might be better tho:

1 Like

It actually is possible I did it for my game, you have to make ur game R15 to copy the animate script and then copy the chunk of code for swimming animations in R15 animate and add it into the R6 animate script. And copy the part where you put the swim anim ids and some other stuff, pretty easy.

1 Like

i added a simple input check that tracks if the player is holding down a movement key in the water part, then applies a custom animation if they do so. if not, it applies a custom idle animation. thanks for the advice though still.

2 Likes

I want to use this, but in my game the swimmable parts are only loaded AFTER the script has run. If I put just one swimmable part in workspace and then load the part in after and add the CollectionService tag, will it still work?

It should work, tell me if it doesn’t

I was using this in my game a few days ago and everything worked perfectly but recently
a few issues came up. First unlike real water terrian when you are moving inside of the part for some reason my player drifts around especially when I change directions. Another issue I am having is how fast the player can swim upwards out of the water. I am not sure if these issues are just for me but this is a normal baseplate with no modifications.

External Media

hey! i had the same problem but after hours of debugging i’ve finally found a solution that closely resemble to the original condition

so i edited the part for the going up forces inside the HighWaterPerformance script into this:

local additionRatioMult = 3
	if table.find(getKeycodesPressed(), Enum.KeyCode.Space) or table.find(getKeycodesPressed(), Enum.KeyCode.ButtonA) then
		local force = hrp:FindFirstChildOfClass("VectorForce")
		if force then
			force.Force = Vector3.new(0, defaultForce * script:WaitForChild("Configuration"):GetAttribute("CharDensityUp") * (hum.WalkSpeed/16 * additionRatioMult), 0) --force that make you go up by pressing space
		end
	
	else
		local force = hrp:FindFirstChildOfClass("VectorForce")
		if force then
			if hum.MoveDirection.Magnitude == 0 then
				if isHeadIn then
					force.Force = Vector3.new(0, defaultForce * script:WaitForChild("Configuration"):GetAttribute("CharDensity") * hum.WalkSpeed, 0) --force that makes you go up by being idle
				end
			else
				force.Force = Vector3.new(0, defaultForce, 0) --force that makes you stay still when floating in the surface
				
			end
		end
	
	end

I added additionRatioMult just for comfy purposes, you can just increase the chardensityup if you’d like to. also feel free to change additionRatioMult to your liking.

And also in the SwimModule script i edited the Start Method into this:

function swimModule:Start()
	if runService:IsServer() then return end
	if self.Enabled then return end
	
	humStates(false, Enum.HumanoidStateType.Swimming) --deactivates the necessary states for swimming to be the priority
	
	local attachment, force = antiGrav(true) --creates the anti grav forces
	
	self.Enabled = true
	
	self.RSConnection = runService.Heartbeat:Connect(function()
		if hum.MoveDirection.Magnitude > 0 then 
			hrp.AssemblyLinearVelocity = Vector3.new(hum.MoveDirection.X * hum.WalkSpeed,  hum.MoveDirection.Y * hum.WalkSpeed , hum.MoveDirection.Z * hum.WalkSpeed) --keeps player moving cohesively by their walkspeed
		else
			hrp.AssemblyLinearVelocity = Vector3.new(0, 0, 0) --resets any kind of build up velocity
		end
	end)
end

All i changed was the runservice.Heartbeat part
Hope this helps and please correct me if i did any mistakes!

4 Likes

if u swim upwards and press space at the same time it flings you up

2 Likes