Character Angular Turning

Hello there.

How could I make an angular turning for my character, very much like in real life vehicles?

The current character scheme of Roblox instantaneously turns your character to whatever direction you’d like to go on its own axis.

What I’m aiming for is a vehicle-type turning, where the turning relies on an offset diameter to perform its path, rather than turning on its own axis.

Reference:
image

So you want the character to move in an arc and rotate to face the movement direction? I haven’t tested this, but it might work.

local RunService = game:GetService("RunService")

local WALK_SPEED = 16

local function moveInArc(char, angle, circleCenter)
    local hum, hrp = char:FindFirstChild("Humanoid"), char:FindFirstChild("HumanoidRootPart")
    if not (hum and hrp) then
        return
    end
    local startPos = hrp.Position
    local xDist, zDist = startPos.X-circleCenter.X, startPos.Z-circleCenter.Z
    local r = math.sqrt(xDist^2+zDist^2)
    local totalArcLen = angle*r -- shortened from (angle/2pi)*2pi*r
   
    local totalT = totalArclen/WALK_SPEED
    local currentT = 0
    
    local startAngle = math.atan2(distX, distZ)
    
    local renderStepConn
    renderStepConn = RunService.RenderStepped:Connect(function(dt)
        currentT += dt
        if currentT >= totalT then
            currentT = totalT
            renderStepConn:Disconnect()
        end
        local currentAngle = startAngle+angle*currentT/totalT
        local circleX = math.sin(currentAngle)*r
        local circleZ = math.cos(currentAngle)*r
        
        local charPos = Vector3.new(circleCenter.X+circleX, hrp.Position.y, cirvleCenter.Z+circleZ)
        local charLookVec = Vector3.new(circleZ, 0, circleX).Unit
        local charCf = CFrame.lookAt(charPos, charLookVec)
        
        hrp.CFrame = charCf
    end
end
1 Like

I had already come up with a solution, just forgot to post it here. But it pretty much uses the same method, creating a circle and finding the X and Z using Sine and Cosine.

Since I know this is a valid method, I’ll give you the solution. Although I haven’t tested it.

1 Like