How to find the angle of a raycast result?

I would like to find the angle of a Raycast result in vector3.

I have found no helpful resources in videos or on the DevForum

I know that (possibly) a dot product is involved in the process of making this.

If anyone is able to help, it would be greatly appreciated, thanks!

1 Like

Could you show a diagram of what you are asking for?


The blue arrow is the raycast coming from a player, I want the raycast to return the angle of the slope in vector3.

Relative to what? The closest thing you’re getting is the normal vector a.k.a the line perpendicular to the surface.

how would i turn a normal into a proper orientation?

I’d probably use math.atan2 (atan2) on each of the components, but I have a suspicious feeling that this isn’t actually what you want. What are you going to use the orientation for?

1 Like

how would i use atan2 on the components?


(apologies for my poor mouse writing)

Also, please answer my question about what you to use this for.

I plan to use this in a script in a simplified version of a gravity controller.

the script uses :pivotTo on the workspace to rotate the workspace and i need to find the angle of a raycast result in vector3 to properly angle the player onto a surface.

Wouldn’t this
a) Cause a bunch of lag
b) Create a disconnect between the server and client
Apologies if I’m completely misinterpreting what you’re saying.

It would probably just be easier to use CFrame:ToWorldSpace() instead of going through all this vector stuff. You do have the part’s CFrame from the raycast, after all.

Not exactly sure if you are looking for something like this


If you are this was what i did

local Result = workspace:Raycast(...)
if Result then
	local Direction = Result.Normal
end
local Orientation = CFrame.new(Vector3.zero, RaycastResult.Normal)