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

How can I edit this script to make it R15 compatible?

Asked by 6 years ago

So I found this Inverse Kinematic script that works for players using R6, but I am wondering if I can make it compatible with R15 and R6. An English answer would be nice.

wait(1)
User = game.Players.LocalPlayer
Humanoid = User.Character.Humanoid
Torso = User.Character.Torso
L_Hip = Torso["Left Hip"]
R_Hip = Torso["Right Hip"]

function ArcTan(x, y)
    r = math.atan(y / x)
if x < 0 then
    r = r + math.pi
end
return r
end

vel = Vector3.new()
while true do
    wait()
    if Torso.Velocity.magnitude > 1 then
        m = (vel - Torso.Velocity).magnitude / Humanoid.WalkSpeed
        vel = (Torso.Velocity * m + vel * 2) / (m + 2)
        v = Torso.CFrame:pointToObjectSpace(vel + Torso.Position)
        L_a = ArcTan(v.x, -v.z)
        R_a = 3.1416 - ArcTan(v.x, v.z)
        L_Hip.C1 = CFrame.new(0, 1, 0)*CFrame.Angles(0, L_a, 0)
        R_Hip.C1 = CFrame.new(0, 1, 0)*CFrame.Angles(0, R_a, 0)
        L_Hip.C0 = CFrame.new(-0.5, -1, 0)*CFrame.Angles(0, L_a, 0)
        R_Hip.C0 = CFrame.new(0.5, -1, 0)*CFrame.Angles(0, R_a, 0)
        L_Hip.MaxVelocity = Torso.Velocity.magnitude / 100
        R_Hip.MaxVelocity = Torso.Velocity.magnitude / 100
    else
        L_Hip.C1 = CFrame.new(0, 1, 0)*CFrame.Angles(0, -1.57, 0)
        R_Hip.C1 = CFrame.new(0, 1, 0)*CFrame.Angles(0, 1.57, 0)
        L_Hip.C0 = CFrame.new(-0.5, -1, 0)*CFrame.Angles(0, -1.57, 0)
        R_Hip.C0 = CFrame.new(0.5, -1, 0)*CFrame.Angles(0, 1.57, 0)
    end
end
0
can you tell me where you put this script? LilJayGamer_PlaysYT 0 — 2y

2 answers

Log in to vote
0
Answered by
LuaDLL 253 Moderation Voter
6 years ago
Edited 6 years ago

Try this?

wait(1)
User = game.Players.LocalPlayer
Humanoid = User.Character.Humanoid
Torso = User.Character.UpperTorso or User.Character.Torso -- If not UpperTorso then It will do Torso for R6 instead of R15
L_Hip = Torso["Left Hip"]
R_Hip = Torso["Right Hip"]

function ArcTan(x, y)
    r = math.atan(y / x)
if x < 0 then
    r = r + math.pi
end
return r
end

vel = Vector3.new()
while true do
    wait()
    if Torso.Velocity.magnitude > 1 then
        m = (vel - Torso.Velocity).magnitude / Humanoid.WalkSpeed
        vel = (Torso.Velocity * m + vel * 2) / (m + 2)
        v = Torso.CFrame:pointToObjectSpace(vel + Torso.Position)
        L_a = ArcTan(v.x, -v.z)
        R_a = 3.1416 - ArcTan(v.x, v.z)
        L_Hip.C1 = CFrame.new(0, 1, 0)*CFrame.Angles(0, L_a, 0)
        R_Hip.C1 = CFrame.new(0, 1, 0)*CFrame.Angles(0, R_a, 0)
        L_Hip.C0 = CFrame.new(-0.5, -1, 0)*CFrame.Angles(0, L_a, 0)
        R_Hip.C0 = CFrame.new(0.5, -1, 0)*CFrame.Angles(0, R_a, 0)
        L_Hip.MaxVelocity = Torso.Velocity.magnitude / 100
        R_Hip.MaxVelocity = Torso.Velocity.magnitude / 100
    else
        L_Hip.C1 = CFrame.new(0, 1, 0)*CFrame.Angles(0, -1.57, 0)
        R_Hip.C1 = CFrame.new(0, 1, 0)*CFrame.Angles(0, 1.57, 0)
        L_Hip.C0 = CFrame.new(-0.5, -1, 0)*CFrame.Angles(0, -1.57, 0)
        R_Hip.C0 = CFrame.new(0.5, -1, 0)*CFrame.Angles(0, 1.57, 0)
    end
end

0
Doesn't work. Moderation_Times -9 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

You need to define the correct limbs and joints for each rig type to make it compatible.

...
Torso = User.Character.HumanoidRootPart
if Humanoid.RigType = Enum.HumanoidRigType.R15 then
    L_Hip = User.Character.LeftUpperLeg.LeftHip
    R_Hip = User.Character.RightUpperLeg.RightHip
else
    L_Hip = Torso["Left Hip"]
    R_Hip = Torso["Right Hip"]
end
...

Edit: Use HumanoidRootPart instead of LowerTorso

Answer this question