High performance water: Swimmable part 2.0

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!

6 Likes

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

2 Likes

does this work with NPCS? onlythirtycharacters

If you change your start function in the swimModule script it will resolve this :slight_smile:

3 Likes

hey, I’m having a problem. so when the swimmable part gets added, when I try to swim in it. there’s a small lag spike and I just fall though it. it works when I reset my character if there’s already the swimmable part in the workspace. here’s a clip of how it looks

(note: it worked before i used LoadCharacter() at the start of the round)
update: fixed. it was because i was anchoring the hrp when i did the load character and that set the default mass to INF… i just set it to the normal (aka 2472.1200363922107)

it was initially showing an error saying there are no compatible parts found (which there were none at the time), but when loading them in with the tag AFTER, it did not detect them

Working right now on a fix for that and some other things

1 Like

thx that’s very cool continue like that brother :smile: !

I have a problem. I selected 2 water meshes with collection service, and for some reason only 1 of them is swimmable. The 2nd one becomes swimmable Only after character dies or resets. even If I select just the 2nd one, it still becomes swimable after reset or death. Am I doing smth wrong, or is it a bug?