#is humanoid:move() a reliable function for advanced movement systems?

1 messages · Page 1 of 1 (latest)

vernal vessel
#
-- basic essential refrences like character, runservice , etc
local targetMoveVelocity = Vector3.new()
local moveVelocity = Vector3.new()
local moveAcceleration = 8


player.CharacterAdded:Connect(function(_character)
    character = _character
end)

local walkKeyBinds = {
    Forward = { Key = Enum.KeyCode.W, Direction = Enum.NormalId.Front },
    Backward = { Key = Enum.KeyCode.S, Direction = Enum.NormalId.Back },
    Left = { Key = Enum.KeyCode.A, Direction = Enum.NormalId.Left },
    Right = { Key = Enum.KeyCode.D, Direction = Enum.NormalId.Right }
}

local function getWalkDirectionCameraSpace()
    local walkDir = Vector3.new()

    for keyBindName, keyBind in pairs(walkKeyBinds) do
        if InputS:IsKeyDown(keyBind.Key) then
            walkDir += Vector3.FromNormalId( keyBind.Direction )
        end
    end

    if walkDir.Magnitude > 0 then 
        walkDir = walkDir.Unit 
    end

    return walkDir
end

local function getWalkDirectionWorldSpace()
    local walkDir = camera.CFrame:VectorToWorldSpace( getWalkDirectionCameraSpace() )
    
    walkDir *= Vector3.new(1, 0, 1) --Set Y axis to 0

    if walkDir.Magnitude > 0 then --(0, 0, 0).Unit = NaN, do not want
        walkDir = walkDir.Unit
    end

    return walkDir
end

local function updateMovement( dt )
    local humanoid = character:FindFirstChild("Humanoid")
    if humanoid then
        local moveDir = getWalkDirectionWorldSpace()
        targetMoveVelocity = moveDir
        moveVelocity = moveVelocity:Lerp(targetMoveVelocity, math.clamp(dt * moveAcceleration, 0, 1) )
        humanoid:Move( moveVelocity )
    end
end    

RunS.RenderStepped:Connect(updateMovement)

in this movement system where it creates a smooth/slippery movement like in counter strike and such , would humanoid:Move be reliable or would it create trouble in the way of development

noble minnow
#

I think you don't understand what move does much at all

vernal vessel
noble minnow
#

okay maybe you do

vernal vessel
#

that point bieng a vector 3 but correct me on that

noble minnow
#

why are you telling it to move based on velocity tho

#

you want the player to autonomously walk towards the direction they're moving in?

vernal vessel
#

not only that but theres a lerp that smoothes out movement

noble minnow
#

that doesn't smooth anything tho it's not like the character gets faster or slower depending on it

vernal vessel
#

imma send a vid

noble minnow
#

ok

vernal vessel
#

take a look at this

vernal vessel
noble minnow
#

you can move sure