I have been making a Parkour script, I have run into numerous problems involving my player facing the wall when attempting to climb it. Here's what I plan to do to. The player presses Shift+space+space to enact the wall climb, but here's where I get stuck because I don't know how to make the player face the wall not curved at all and then climb it. I was thinking I would just ray-cast forward, but then what would I do next? I Attempted to look how to use the cross product Roblox provides us with the problem with that is obvious and it will not work 70% of the time.
My cross product attempt
local h, p, n = workspace:FindPartOnRay(ray, chr.HumanoidRootPart) local cross = Vector3.new(0, 1, 0):Cross(n) local angle = math.asin(cross.magnitude) chr.HumanoidRootPart.Anchored = true chr.HumanoidRootPart.CFrame = CFrame.new(position + n * chr:GetModelSize().y/2) -- position * CFrame.fromAxisAngle(cross.magnitude == 0 and Vector3.new(1) or cross.unit, angle ) print(chr.HumanoidRootPart.CFrame.Y) if chr.HumanoidRootPart.Rotation.X == -90 then print("O.O") chr.HumanoidRootPart.CFrame = chr.HumanoidRootPart.CFrame * CFrame.Angles(math.rad(180),0,math.rad(-180)) elseif chr.HumanoidRootPart.Rotation.Z == 90 then chr.HumanoidRootPart.CFrame = chr.HumanoidRootPart.CFrame * CFrame.Angles(math.rad(0),math.rad(-90),math.rad(00)) elseif chr.HumanoidRootPart.Rotation.Z == -90 then chr.HumanoidRootPart.CFrame = chr.HumanoidRootPart.CFrame * CFrame.Angles(math.rad(0),math.rad(90),math.rad(00)) --CFrame. end
Yes, very basic I know, but I'm stumped I'm improvising.
Can anyone provide me with an example of how I am to make the character CFrame perpendicular to the black he/she is trying to attach to? Thank you.