#how to make invariable walkspeed

11 messages · Page 1 of 1 (latest)

spiral pollen
#

the problem is when i increase y orientation moving my camera up or down it subtracts from x and z, decreasing the walkspeed of the rig

I need a way to stop y from affected the x and z

(sorry for posting a lot of threads on this function)

#
function Movement(player, humanoid:Humanoid, keys, cameracframe:CFrame)
    local x, z = 0, 0
    local lv = cameracframe.LookVector.Unit
    local rd = cameracframe.RightVector.Unit

    if keys["W"] == true then
        x += lv.X
        z += lv.Z
    end
    if keys["S"] == true then
        x -= lv.X
        z -= lv.Z
    end
    if keys["A"] == true then
        x -= rd.X
        z -= rd.Z
    end
    if keys["D"] == true then
        x += rd.X
        z += rd.Z
    end

    local tweenInfo = TweenInfo.new(
        0.05,
        Enum.EasingStyle.Linear,
        Enum.EasingDirection.Out
    )
    local tweenGoal = {Position = humanoid.Parent.HumanoidRootPart.Position + Vector3.new(x, 0, z)}
    local tween = game:GetService("TweenService"):Create(humanoid.Parent.HumanoidRootPart, tweenInfo, tweenGoal)
    tween:Play()
    humanoid.Parent:PivotTo(CFrame.new(humanoid.Parent:GetPivot().Position, humanoid.Parent:GetPivot().Position + 
        Vector3.new(cameracframe.LookVector.X,0,cameracframe.LookVector.Z)))
end
wide swallow
#

uhh, damn

#

try using runservice or find a way to detect change

#

and then when it does

#

just set the x and z thingy to the value you want

spiral pollen
wide swallow
#

oh your talking about rotation?

#

up and down is the Z axis i think