What is happening here?
local vector = (HRP.CFrame - HRP.CFrame.p):VectorToObjectSpace(surfaceHit)
My assumption: its taking the HRP’s CFrame, and removing the positional values.
- So now we are left with the rotational values?
- then it takes the offset between the HRP’s CFrame rotational values, and a Vector3? - How is that possible if Vector3’s dont have rotational values?
FULL CODE:
Code Function - Slope Tilting
local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local lowerTorso, HRP = char:WaitForChild("LowerTorso"), char:WaitForChild("HumanoidRootPart")
game:GetService("RunService").RenderStepped:Connect(function()
local ray = Ray.new(HRP.Position, Vector3.new(0, -(char.Humanoid.HipHeight + 2), 0))
local _, _, surfaceHit = workspace:FindPartOnRayWithIgnoreList(ray, {char})
local vector = (HRP.CFrame - HRP.CFrame.p):VectorToObjectSpace(surfaceHit) -- The code being mentioned
print(surfaceHit.CFrame)
print(vector)
lowerTorso.Root.C0 = CFrame.new(0,-0,0,1,0,0,0,1,0,0,0,1) * CFrame.Angles(vector.z, 0, -vector.x)
end)