When A raycast hits something. I want to be able to tell what position it hit at

I want to be able to tell if when A raycast fires and hits an object, I want to be able to tell where it hit in vector3

For example
A raycast fires.
It hits an object the position where the ray touched the part is vector3

Basically I just need to tell where it touches. Like kind of like mouse.hit.p

A raycast can tell you where it hit (I think if you use workspace:Raycast()), like this:

local result = workspace:Raycast(position, direction, RaycastParams) -- raycast

if result then -- if the ray intersected something
    print(result.Position) -- intersected point
end

If you want to get the Intersected face, you would add the Normal Vector:

print(result.Position + result.Normal)

very simple. we can simply use the position value:

local raycast = workspace:Raycast(script.Parent.Position,script.Parent.CFrame.LookVector * 10)
if raycast then
	workspace.point.Position = raycast.Position
end

position is intersected point between ray for elaboration or just intersected point in this case

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