#Custom shiftlock character fling issue

1 messages · Page 1 of 1 (latest)

midnight forge
#

So basically i am attempting to make a game similar to bridger western. I am currently in the process of creating the shiftlock system.
Whats different about the bridger western shiftlock is that it faces ur character directly at where ur facing, so if i was facing down my character would face that way.
Its practically complete except the character keeps flinging when looking downwards. I want the Ys Cframe to be changed, just not the flinging part. Any suggestions on how to fix this issue?

#

Heres the snippet:

#
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local character = plr.Character
local humanoid = character:WaitForChild("Humanoid")
local rootPart: BasePart = character:WaitForChild("HumanoidRootPart")
local camera = workspace.CurrentCamera

local OTHER = {}
local T1 = TweenInfo.new(0.2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local renderConnection = nil
local Shiftlocked = false

local function rotateCharToCamera(dt)
    local lookVector = camera.CFrame.LookVector
    local flatLook = Vector3.new(lookVector.X, 0, lookVector.Z)
    if flatLook.Magnitude == 0 then return end

    local targetCFrame = CFrame.new(rootPart.Position, rootPart.Position + flatLook)
    rootPart.CFrame = rootPart.CFrame:Lerp(targetCFrame, math.clamp(dt * 20, 0, 1))
end

local function tweenOffset(bool)
    if bool then
        UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
        UserInputService.MouseIcon = "rbxassetid://11232270592"
        TweenService:Create(humanoid, T1, { CameraOffset = Vector3.new(2, 0, 0) }):Play()
        humanoid.AutoRotate = false
        
        renderConnection = RunService:BindToRenderStep("Shiftlock", 200, rotateCharToCamera)
    else
        UserInputService.MouseBehavior = Enum.MouseBehavior.Default
        UserInputService.MouseIcon = ""
        TweenService:Create(humanoid, T1, { CameraOffset = Vector3.new(0, 0, 0) }):Play()
        humanoid.AutoRotate = true
        
        RunService:UnbindFromRenderStep("Shiftlock")
    end
end

function OTHER.Shiftlock(key, state)
    if state == Enum.UserInputState.Begin then
        Shiftlocked = not Shiftlocked
        tweenOffset(Shiftlocked)
    end
end

return OTHER```
modest olive
# midnight forge ```local TweenService = game:GetService("TweenService") local RunService = game:...

you directly set rootpart cframe every frame while also letting physics and humanoid try to control it
when you look down the camera lookvector has a strong y value
even tho you zero it out after that the fast lerp + direct cframe set still fights physics and causes fling
the best way to fix (maybe) is to rotate using orientation only not full cframe
so we keep position untouched and only rotate on y axis

#

here try this

midnight forge
#

ty ty

midnight forge