Hello,
I want to make it so the character’s torso rotation matches the floor normal vector, not by simply ajusting it’s CFrame, but by adjusting the Root Joint’s C0 value (Root Joint is the Motor6D from HumanoidRootPart to Torso)
The following picture better illustrates the desired result:
What is the issue? I don’t really know how to do it ;p
This is my script so far:
local floorNormal = Vector3.new()
function onUpdate(dt)
local rayParams = RaycastParams.new()
rayParams.FilterType = Enum.RaycastFilterType.Whitelist
rayParams.FilterDescendantsInstances = {workspace.Level}
local origin = hrp.Position
local target = Vector3.new(0,-8,0)
local raycastResult = workspace:Raycast(origin,target,rayParams)
local hitPos = hrp.Position + target
if raycastResult then
hitPos = raycastResult.Position
floorNormal = raycastResult.Normal
else
floorNormal = Vector3.new()
end
-- RootJoint.C0 = RootJoint.C0 * ??? i don't know what to do here
end;
game["Run Service"].RenderStepped:Connect(onUpdate)