How do we make Inverse Kinematics?
Please encode Lua code in the Lua block code tag (look for the Lua icon in the editor).
I never asked for the damn code mods so don't even try closing this.
Just need some help with IK kinematics (aka dynamic movement) the problem is I don't know how the hell to make it and I get errors in the process of the code.
Code:
02 | User = game.Players.LocalPlayer |
03 | Humanoid = User.Character.Humanoid |
04 | Torso = User.Character.LowerTorso |
05 | L_Hip = Torso [ "Left Hip" ] |
06 | R_Hip = Torso [ "Right Hip" ] |
08 | local step = game:GetService( 'RunService' ).RenderStepped; |
21 | local velVector = Vector 3. new(Torso.Velocity.X, 0 ,Torso.Velocity.Z); |
22 | if velVector.magnitude > 0 then |
23 | m = (vel - Torso.Velocity).magnitude / Humanoid.WalkSpeed |
24 | vel = (Torso.Velocity * m + vel * 2 ) / (m + 2 ) |
25 | v = Torso.CFrame:pointToObjectSpace(vel + Torso.Position) |
26 | L_a = ArcTan(v.x, -v.z) |
27 | R_a = 3.1416 - ArcTan(v.x, v.z) |
28 | L_Hip.C 1 = CFrame.new( 0 , 1 , 0 )*CFrame.Angles( 0 , L_a+math.pi, 0 ) |
29 | R_Hip.C 1 = CFrame.new( 0 , 1 , 0 )*CFrame.Angles( 0 , R_a+math.pi, 0 ) |
30 | L_Hip.C 0 = CFrame.new(- 0.5 , - 1 , 0 )*CFrame.Angles( 0 , L_a-math.pi, 0 ) |
31 | R_Hip.C 0 = CFrame.new( 0.5 , - 1 , 0 )*CFrame.Angles( 0 , R_a-math.pi, 0 ) |
32 | L_Hip.MaxVelocity = Torso.Velocity.magnitude / 100 |
33 | R_Hip.MaxVelocity = Torso.Velocity.magnitude / 100 |
35 | L_Hip.C 1 = CFrame.new( 0 , 1 , 0 )*CFrame.Angles( 0 , - 1.57 , 0 ) |
36 | R_Hip.C 1 = CFrame.new( 0 , 1 , 0 )*CFrame.Angles( 0 , 1.57 , 0 ) |
37 | L_Hip.C 0 = CFrame.new(- 0.5 , - 1 , 0 )*CFrame.Angles( 0 , - 1.57 , 0 ) |
38 | R_Hip.C 0 = CFrame.new( 0.5 , - 1 , 0 )*CFrame.Angles( 0 , 1.57 , 0 ) |