#Torso leaning according to lookVector
53 messages · Page 1 of 1 (latest)
whats dat
google it
how am i gonna apply that here tho?
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
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)
do whatever works for u
i think im not supposed to make this mechanic the way im doing in the first place, this does not work btw (after adding math.clamp)
still thanks
what ur supposed to do is
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
camera direction
im trying to move torso up and down according to if camera is looking up or down
rotate or move?
ok so ur basicly trying to make
rotate
this
yes
ok so
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
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)
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 something like thijs?
yep
yeah i was doing that in first script i sent but i couldn't figure out some stuff
can you review it?
it's at very top of the post
so i was on the right path and bootycooker made me change everything and now its even more broken
yea
@green parcel
Give me a second
h
@green parcel can you check dms?