#Sliding steer problem

1 messages · Page 1 of 1 (latest)

dry cape
#

Does anyone know why this causes the sliding to face another direction instead of going forward? im genuinely crine

#
        local move = hum.MoveDirection

        if move.Magnitude > 0 then

            local cam = workspace.CurrentCamera
            local camCF = cam.CFrame

            local forward = Vector3.new(camCF.LookVector.X,0,camCF.LookVector.Z).Unit
            local right = Vector3.new(camCF.RightVector.X,0,camCF.RightVector.Z).Unit

            local desiredDir = (forward * move.Z) + (right * move.X)

            if desiredDir.Magnitude > 0 then

                local speed = slideVelocity.Magnitude
                local currentDir = slideVelocity.Unit
                local targetDir = desiredDir.Unit

                local angle = math.acos(math.clamp(currentDir:Dot(targetDir), -1, 1))

                if angle > 0 then
                    local maxTurn = slideSteerStrength * dt
                    local t = math.min(1, maxTurn / angle)

                    local newDir = currentDir:Lerp(targetDir, t).Unit
                    slideVelocity = newDir * speed
                end

            end
        end
#

(same scripts diff format)

#

for some fucking reason

#

it turns a different way

#

💔

#

(btw i got too desperate and tried to fix it with ai if someone here is gonna ask "did you skid this")

silver hornet
#

Someone help p

urban plank
#

@dry cape

#

local move = hum.MoveDirection

if move.Magnitude > 0 then
local desiredDir = move

local speed = slideVelocity.Magnitude
local currentDir = slideVelocity.Unit
local targetDir = desiredDir.Unit

local dot = math.clamp(currentDir:Dot(targetDir), -1, 1)
local angle = math.acos(dot)

if angle > 0 then
    local maxTurn = slideSteerStrength * dt
    local t = math.min(1, maxTurn / angle)

    local newDir = currentDir:Lerp(targetDir, t).Unit
    slideVelocity = newDir * speed
end

end

#

try that out

#

tell me if it works or not

#

MoveDirection is already a world-space vector that accounts for the camera. When you do (forward * move.Z) + (right * move.X), you are essentially calculating the camera relative direction a second time.

#

@dry cape

#

does it work?