Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I create an orientation from a look vector?

I have a look vector, either a Surface Normal from a raycast, or (position1-position2).Unit, or some look vector. How do I transform it into an orientation, so I can assign a part's orientation to match the look vector?

2 comments

0

Do you want to rotate the part so the parts front surface "looks" at the LookVector?

0

Yes

1 answer

You could do some math here, but there is a built-in CFrame:ToOrientation() method.

local cf = cframehere
local orientation = Vector3.new(cf:ToOrientation())

I'm not 100% sure, but I remember something about ToOrientation returning 3 values and not a Vector3, may need to double-check that.

1 comment

0

I don't have a CFrame, I have a Vector3

This discussion is preserved as it was. New answers, comments, and votes are closed.