Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I convert my CFrame in WorldSpace to a value for a joint?

Asked by 6 years ago

I made a script that makes it easy to make a character hold a gun, this script calculates the CFrame of the arms(it's in R15). The only problem with this is, it's in WorldSpace and these arms are connected to a character with joints, so instead of CFraming these arms, I need to change a value in the joints(like C0 or C1). I have an attempt that I thought would work below, but yeah... It didn't work.

----Applying Calculations
    local RUt = ROrigin*CFrame.Angles(0, RAlpha, 0)*CFrame.new(0, 0, -UpperSize/2)
    local RLt = RUt*CFrame.new(0, 0, -UpperSize/2)*CFrame.Angles(0, RBeta, 0)*CFrame.new(0, 0, -LowerSize/2)
    ------Corrections
    RUt = RUt*CFrame.Angles(math.pi/2, math.pi/2, 0)
    RLt = RLt*CFrame.Angles(math.pi/2, 0, 0)*CFrame.new(0, 0.5, 0)
    ----To C0
    RU.RightShoulder.C0 = script.Parent.UpperTorso.CFrame:inverse()*RUt
    RL.RightElbow.C0 = RU.CFrame:inverse()*RLt

RUt and RLt are the CFrames that the RightUpperArm and RightLowerArm should have in World Space, the last two lines are an attempt in converting this to the input needed in C0.

0
Okay, changing the C1 to CFrame.new(0, 0, 0) seemed to fix that, but now there's still the issue that the player just dies as soon as I set the C0 value... HarrySnotte 7 — 6y

Answer this question