Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do we make swimmable water? (Not Terrain Water)

Asked by 3 years ago

I keep trying to make swimmable water in Roblox, and then it just turns into a failure. The animations won't work nor the user input service. I'm trying to make the water where you can basically swim dive down w/ shift and go up w/ space. Just doesn't work.

0
You can send me the coding but I prefer coding it myself, If you send the code to me i'll just learn from it and code it. DayLighter_1995 8 — 3y

1 answer

Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
3 years ago
Edited 3 years ago

I answered this question a long time ago on the developer forum, so here's the gist:

You use a BodyVelocity with the MaxForce on each axis set to math.huge and set the Velocity property to the current MoveDirection of their Humanoid (for this to work easily with mobile / console users too) multiplied by a desired speed (I used 16) to get the velocity. You just need to integrate diving / surfacing by using UserInputService to detect inputs and apply to the velocity, like:

local UP = 0
local Down = 0

UserInputService.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.SpaceBar then
        UP = 1
    elseif input.KeyCode == Enum.KeyCode.LeftShift then
        Down = 1
    end
end)

-- // Handle InputEnded event and set the variables to 0 if the keys have been released

local y = UP - Down
BodyVel.Velocity = TargetedVelocity + Vector3.new(0, y, 0)

Doing this will give you the same results I did in this place long ago and even Flood Escape 2's

0
Thank you sir! DayLighter_1995 8 — 3y
Ad

Answer this question