Actual Behavior
When Humanoid:SetStateEnabled() is used to disable swimming, the character is still affected by the lessened gravity while in water. As a result, characters consistently fall slower than when not in water.
Expected Behavior
Characters should have no difference in behavior when entering water while Enum.HumanoidStateType.Swimming is disabled.
Reproduction
Rate: Always
Place Enum.Material.Water
Disable Enum.HumanoidStateType.Swimming in a local script
Jump outside of water and observe fall duration
Jump while in water and observe increased fall duration
Thanks for the report! Disabling the swimming state does not necessarily turn off the effect of water physics on the character, it has more to do with the animation and control of the character. If you would like to totally remove all the effect of the water on the character, the standard way is to disable collisions between the character and the terrain.
Please correct me if I’m wrong, but this results in the player being unable to interact with any terrain to my knowledge. Is there a workaround such that the player is only unaffected by the lower gravity of water?
That’s a good point! However, I think there is some subtlety here: I think you want to just disable collisions between the HumanoidRootPart and Terrain. In my testing this prevents the entire humanoid from being affected by water physics, but collision between terrain and all of the rest of the humanoid parts still happens (so you can walk on grass, for instance).
This is really just abusing a less-than-ideal design, but in the coming months I will be re-designing how water physics is applied, and it will hopefully be easier to turn off water physics individually with the new system.
Thanks for the proposed workaround. I gave it a shot, but it doesn’t seem to demonstrate the described behavior. Despite disabling collisions between terrain and the HumanoidRootPart, the character still has an increased fall duration while in water. I also tried using a NoCollisionConstraint between the two, but that didn’t work either. Did you approach this in any specific way? Did you test it on an internal build or with a specific beta feature enabled?
I used the following and validated that it’s running by disabling the collisions of all character BaseParts; however, HumanoidRootPart alone does not display a difference in behavior.
Hmm you are totally right - It’s weird there still seem to be some contact points being generated, even when I think I am turning off all collisions, and these seem to generate just enough force to slow the character down a little. I will dive into this further. Thank you for giving it a shot!
Apologies for the delay - Unfortunately, we do not currently have a nice, built-in way to only turn off collisions with water and not the rest of the terrain. You can try and develop a workaround based off something like raycasting down/in the direction of movement to try and adaptively turn on/off collisions with terrain based on if you are in water or not.
In the first half of next year we plan on releasing a revamped hydrodynamic system which should make it possible to turn off water physics without turning off collisions, but unfortunately we do not want to introduce any new APIs in the meantime which may confuse things.