#Torso leaning according to lookVector

53 messages · Page 1 of 1 (latest)

atomic sparrow
#

math.clamp

warm hemlock
atomic sparrow
#

google it

warm hemlock
atomic sparrow
#

bro you only have 1 fucking equation

#

😭

#

also i would personally put leaning amount outside of the connection

#

and increase/decrease/reset it each time depending on what the player does

#

so it functions like a tween

warm hemlock
# atomic sparrow bro you only have 1 fucking equation

like this? ;P

local RunService = game:GetService("RunService")
local Players = game:GetService("Players")

local Player = Players.LocalPlayer
local Camera = workspace.CurrentCamera

local Character = Player.Character or Player.CharacterAdded:Wait()
local UpperTorso = Character:WaitForChild("UpperTorso")

local motor = UpperTorso:FindFirstChild("Waist")

local MIN_LEAN = -15
local MAX_LEAN = 15

RunService.RenderStepped:Connect(function(deltaTime)
    local lookVector = Camera.CFrame.LookVector

    local leanAmount = 0

    if lookVector.Y > 0.1 then
        leanAmount = -lookVector.Y * 15
    elseif lookVector.Y < -0.1 then
        leanAmount = -lookVector.Y * 15 
    end
    
    leanAmount = math.clamp(leanAmount, MIN_LEAN, MAX_LEAN)

    if motor then
        local currentC0 = motor.C0
        motor.C0 = currentC0 * CFrame.Angles(math.rad(leanAmount), 0, 0)
    end
end)
atomic sparrow
#

do whatever works for u

warm hemlock
#

still thanks

atomic sparrow
#

hold on

#

why do u need to determine what lookvector is every .renderstepped

#

are u trying to lean ur character according to the humanoid movedirection or the camera direction and character velocity

warm hemlock
#

im trying to move torso up and down according to if camera is looking up or down

atomic sparrow
#

ok so ur basicly trying to make

warm hemlock
atomic sparrow
warm hemlock
atomic sparrow
#

ok so

warm hemlock
#

where did you get that from

#

lol

atomic sparrow
#

i drew it

#

basicly get the axis that rotates ur torso

#

get the camera lookvector and mess with it until it gives you -1 when you look as down as possible and 1 when you look as up as possible

#

then use that number to rotate ur torso

#

by multiplying it by the max degree amount like 60

#

then u can as a safety measure cap it with this code math.clamp(result,-60,60) which caps it at 60 degrees both ways

warm hemlock
#

So like this? @atomic sparrow

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local torso = character:WaitForChild("UpperTorso")

local maxRotation = 60

game:GetService("RunService").RenderStepped:Connect(function()
    local camera = workspace.CurrentCamera
    local lookVector = camera.CFrame.LookVector

    local yDirection = lookVector.Y

    local result = yDirection

    local rotationAmount = result * maxRotation

    local clampedRotation = math.clamp(rotationAmount, -maxRotation, maxRotation)

    torso.CFrame = torso.CFrame * CFrame.Angles(math.rad(clampedRotation), 0, 0)
end)
atomic sparrow
#

im not readinga llat

#

u got this though

green parcel
#

holy i see why your s1

#

Help the damn dude

#

@warm hemlock you should use the UpperTorso.Waist

#

Since its a motor6d

#

you could modify it according to the lookvector

#

I have something likoe this

warm hemlock
warm hemlock
#

can you review it?

#

it's at very top of the post

warm hemlock
green parcel
#

yea

warm hemlock
green parcel
#

Give me a second

fresh star
#

h

warm hemlock
#

@green parcel can you check dms?