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

How to properly use lookVector?

Asked by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

I've read the wiki page that includes lookVector, but it only provides a one sentence explanation. How would one use it to determine which way it is facing? Currently, I'm trying to make a sliding door and I want it to work whichever way the door is facing. Little help?

1 answer

Log in to vote
9
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

The lookVector of a CFrame is a unit vector pointing in the direction of the CFrame's forward direction (-z in object space) or front face.

If the door's front face points the way you want it to move, then the math would look something like

startCFrame = part.CFrame

slideAmount = 5 -- Studs to slide

slideDirection = part.CFrame.lookVector -- Direction to slide in

slideCFrame = startCFrame + slideDirection * slideAmount -- Start + Motion

0
Thank you very much! Also, *direction Shawnyg 4330 — 10y
Ad

Answer this question