So I’m making a parkour game and before this issue, I’ve made the character successfully face the wall when it wants to scale the wall.
Anyway, that was for climbing, right now I’m making the second part allowing the player to wall-run which also works fine, the only thing I want to add is to make the character face the wall it’s running, but sideways. this works for walls that are rotated -45 degrees, but not on walls in other directions. I’m trying to make this dynamic and I’ve tried several things.
CFrame_Line*CFrame.Angles(0,math.deg(90),0)
--or
CFrame_Line*CFrame.Angles(0,math.rad(90),0)
--tried this knowing full well radians wouldn't
--work anyway since I lost hope in myself
but none proved any different.
right now I have footage of it working on 1 type of wall in a particular direction, and also not working on other wall directions:
The constructor is CFrame.lookAt(), and you’ll need to perform a raycast too. Here’s some pseudo-code for further assistance.
local Workspace = workspace
local Parameters = RaycastParams.new()
Parameters.FilterDescendantsInstances = {Character} --Make sure the character is blacklisted.
local Result = Workspace:Raycast(HumanoidRootPart.Position, HumanoidRootPart.CFrame.RightVector * 5, Parameters) --Perform raycast from character's root to 5 studs right of character's root (or left if necessary).
if Result then
HumanoidRootPart.CFrame = CFrame.lookAt(HumanoidRootPart.Position, Result.Position) * CFrame.Angles(0, math.pi / 2, 0) --Look at specific wall position from current position and rotate the character 90 degrees around the Y-axis (may need to be -90 degrees).
end