How to angle a part in the direction of another parts normal without an angle

So I raycast to find a wall and place a part where the raycast hit but I want it to face the normal of the part, the issue is that if I do so and the part that the raycast hit is big then the normal will face the center of the part.

How do I go about making it unangled but still facing the normal on any side of a part that the raycast hits?

I did something like below and I’m not good with CFrames so idk
PlacePart.CFrame = CFrame.lookat(RaycastResult.Position, RaycastResult.Normal)

image
In my amazing illustration, I show that when the raycast hit’s a corner or anywhere away from the center face of the part being hit, when CFramed to look at the Normal it angles, I just want it to angle the same way the face hit angles (flat).

It should be

PlacePart.CFrame = CFrame.lookat(RaycastResult.Position, RaycastResult.Position + RaycastResult.Normal)

CFrame.lookAt positions the CFrame at one place and have it look at another. The .Normal vector is always relative to the hit position itself, not the world, so you have to add it to the position.

1 Like

Oh my, I had fixed this in the past and completely forgot, I ended up asking chat gpt before I saw this and got a 5 liner of math but it worked the same. Thankyou, I didn’t even realize lol.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.