How would I make a part where you can swim in it with custom swimming controlls?

Basically, im making a 3d platformer, and I wanna have water as a part, but i don’t want roblox’s swimming controls. I want something similar to mario 64. how could I do this?

You create a part (which will be the hitbox), check that if the player is inside of this hitbox then change the players movement to your custom movement and then play a looped animation or smth

1 Like

I haven’t played Super Mario 64 in a while, so I found this video that describes the movement under water.

From a movement perspective, Mario stays still in water when there’s no input/movement by the player. Press the A button, or the ‘go forward button’ to move forward. If you do this when holding the thumbstick down on the controller, Mario swims up. Hold the thumbstick up, and press the A button, and then Mario swims downwards.

How “custom” you want the implementation to be can vary. I assume you’re using a Humanoid and a custom character with a HumanoidRootPart. But if not, I can try helping past that. There are many ways to go about this; I’m not sure the “best” way for each step.

List of Resources:

  • Use UserInputService to get the player’s input.
  • Use the player’s CFrame.LookVector to know where ‘forward’ is for the player.
  • Use ZonePlus instead of Roblox’s Touched events to detect when a player enters a region.
    • This is what I do for the water in my current 3d platformer. I’ve noticed some performance issues on Mobile, but I’m not sure if I can attribute that to ZonePlus.
  • If you have a Humanoid character, you can utilize the following:
    • The StateChanged event allows you to know when the player is Jumping, in Freefall, and all these other Enums. Note that Roblox does have a Swimming Enum here, but that’s for when the player is swimming in Roblox’s Terrain water.
    • The humanoid.MoveDirection.Magnitude can be used to know if the player is moving, or standing still. If the value is equal to zero, then the player is standing still.
    • Use the humanoid:GetPropertyChangedSignal("FloorMaterial") event to get the Air, or other, materials the player is ‘standing’/‘moving’ on.
      • The way I implemented the water in my game, it checks for many things due to other movement mechanics, but one thing I check for is if the player is in the ‘Air’ when in water. This is because I want the player to be able to ‘land’ on floors/areas in underwater parts of my game.
  • LinearVelocity can be used to move the player in a direction you want to.
    • I use a Line velocity instead of a vector, but my way of doing it makes the player move based on the default controls in the X and Z, and the additional movement by the LinearVelocity is the Y-axis. That allows for a ‘naturally’ feeling control scheme I guess, and it lets me make the player ‘sink’ or ‘float’ by changing one number.

Note: If you want your game to support mobile, the swimming included, be aware that setting the Player’s Humanoid JumpPower to zero gets rid of Roblox’s jump button. I got around this by doing the following:

humanoid.JumpPower = 0.000000001

Hope this helps! Feel free to ask any questions about anything and I’ll try my best to help where I can. 3D Platformers are my bread and butter, so yeah. :>

1 Like

Thanks for all this info, ill try some stuff tomorrow and get back to you!

1 Like