Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I create an orientation from a look vector?

Asked by
nc2r 117
3 years ago
Edited 3 years ago

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?

0
Do you want to rotate the part so the parts front surface "looks" at the LookVector? PhantomBrix 40 — 3y
0
Yes nc2r 117 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

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.

0
I don't have a CFrame, I have a Vector3 nc2r 117 — 3y
Ad

Answer this question