creating a mantling system that will have the player facing the wall they climb
HumanoidRootPart.CFrame = CFrame.lookAt(HumanoidRootPart.Position, Vector3.new(part.Position.X, HumanoidRootPart.Position.Y, part.Position.Z))
The issue is that my character looks at the middle/origin of the part they attempt to climb, i want them to face the same direction as the part in front of me
i use this to look at the part, i get the part by raycasting, i have the parts normal but i do not know how to make the character face the same direction as the raycastresult normal
can someone help me?
HumanoidRootPart.CFrame = CFrame.lookAt(HumanoidRootPart.Position, raycast.Normal)
Still cannot get it to work even with this
CFrame.lookAt() doesn’t use the second parameter as a direction, instead it uses the second parameter as the target point that the position is supposed to be looking at, this means that this code is making the character look towards a point that is moved 1 stud in the direction of the raycast normal from the world origin instead of making it look in the direction of the raycast normal, you can fix this by adding HumanoidRootPart.Position to the normal.
Also to fix the character looking away from the wall instead of looking at the wall you need to use negative raycast normal since the raycast normal is a vector that’s looking away from the surface that the ray hit
Here’s the updated code
HumanoidRootPart.CFrame = CFrame.lookAt(HumanoidRootPart.Position, HumanoidRootPart.Position - raycast.Normal)