Getting angle from NormalId

Hello!

I’m working on a wall jump mechanic along with a bunch of other stuff and I was just wondering how I would go about making it so I can make the HumanoidRootPart rotate depending on the normal that was hit when the player touched the wall jumper? Right now, regardless of the position I’ve hit the wall jumper from, it always makes me angled at 0,0,0

image

Ideally, it would face me away from the direction that I’ve touched the normal from.

So for example, I hit this face, I should be facing the way the red line is facing:
image

Any ideas of how I’d do this?

Here’s what I have so far:

        v.Touched:Connect(function(otherPart)
			if isInWall then
				return
			end
			if otherPart:GetAttribute('WallJumper') then
				raycastParams.FilterDescendantsInstances = {otherPart}
				local ray = workspace:Raycast(humanoidRootPart.Position, humanoidRootPart.CFrame.LookVector * 100, raycastParams) -- casts a ray using the HumanoidRootPart's LookVector to ensure they're facing the wall jumper, I don't want them to get stuck if they aren't looking at it, and I don't want them to get stuck if they're on the top or on the bottom
				if ray and ray.Instance == otherPart then -- then they should stick to the wall
					local instance = ray.Instance :: BasePart
					local normal = ray.Normal
					humanoidRootPart.CFrame = CFrame.new(ray.Position) -- positions them as it should be, not sure how to get the angle tho
					isInWall = true
					humanoidRootPart.Anchored = true
					torso.Anchored = true
				end
			end
		end)

You can use CFrame.lookAt and to face the normal, you can add it to the player’s position:

humanoidRootPart.CFrame = CFrame.new(ray.Position, ray.Position + ray.Normal)
1 Like
humanoidRootPart.CFrame = CFrame.lookAt(ray.Position, ray.Position + normal)

Might be good enough for you.

1 Like