Hey! So recently in a game, I was shown this:
https://gyazo.com/409c245c4a46e48bc239d40d045ddfbd
now, I’ve done my research but I was unable to figure how to create this.
My first guess would be editing the Motor6D
rigs’s orientation. Another person suggested using BodyGyro
to tilt the character but that didn’t go well.
EDIT: I’m also going to assume that this will be done on the client since the client character replicate’s to the server.
It seems like my methods aren’t as smooth as this.
Any information regarding this is appreciated.
EDIT:
After much researching I’ve found a working script that you are free to copy and paste:
--|| SERVICES ||--
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
--|| VARIABLES ||--
local Player = Players.LocalPlayer
local Character = script.Parent
local Humanoid = Character:WaitForChild"Humanoid"
local HumanoidRootPart = Character.HumanoidRootPart
local Torso = Character.Torso
local RootJoint = HumanoidRootPart.RootJoint
local LeftHipJoint = Torso["Left Hip"]
local RightHipJoint = Torso["Right Hip"]
local function Lerp(a, b, c)
return a + (b - a) * c
end
local Force = nil
local Direction = nil
local Value1 = 0
local Value2 = 0
local RootJointC0 = RootJoint.C0
local LeftHipJointC0 = LeftHipJoint.C0
local RightHipJointC0 = RightHipJoint.C0
RunService.RenderStepped:Connect(function()
--> To get the force, we multiply the velocity by 1,0,1, we don't want the Y value so we set y to 0
Force = HumanoidRootPart.Velocity * Vector3.new(1,0,1)
if Force.Magnitude > 2 then
--> This represents the direction
Direction = Force.Unit
Value1 = HumanoidRootPart.CFrame.RightVector:Dot(Direction)
Value2 = HumanoidRootPart.CFrame.LookVector:Dot(Direction)
else
Value1 = 0
Value2 = 0
end
--> the values being multiplied are how much you want to rotate by
RootJoint.C0 = RootJoint.C0:Lerp(RootJointC0 * CFrame.Angles(math.rad(Value2 * 10), math.rad(-Value1 * 10), 0), 0.2)
LeftHipJoint.C0 = LeftHipJoint.C0:Lerp(LeftHipJointC0 * CFrame.Angles(math.rad(Value1 * 10), 0, 0), 0.2)
RightHipJoint.C0 = RightHipJoint.C0:Lerp(RightHipJointC0 * CFrame.Angles(math.rad(-Value1 * 10), 0, 0), 0.2)
end)
This is for R6, to use it place a LocalScript
into StarterCharacterScripts
and paste the contents in there. Enjoy!