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

What is upvector and rightvector used for?

Asked by 4 years ago
Edited 4 years ago

I can't see any use in them when you have lookvector. Plus, they seem to not be working. I tried everything and nothing happend.

while wait() do
    workspace.hi.Position = game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame.UpVector
    print(game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame.UpVector)
end


0
because directional unit vectors aren't meant for use for positions theking48989987 2147 — 4y

2 answers

Log in to vote
2
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

LookVector, RightVector and UpVector

UpVector returns a direction facing upwards of a CFrame, RightVector returns a direction facing the right of a CFrame, and LookVector returns a direction facing forwards of a CFrame.

These are returned as Vector3's and are normalized, meaning that they have a magnitude approximately equal to 1; have used .Unit on them

These can be used for:

Propelling a character forwards:

Suppose you want a player to propel themselves forward or in any other direction with a small force. You can use:

local bv = Instance.new("BodyVelocity")

bv.Velocity = player.Character.HumanoidRootPart.CFrame.lookVector * 50 -- moving them at a velocity of 50 studs forwards
bv.MaxForce = Vector3.new(1, 1, 1) * math.huge
bv.Parent = player.Character.HumanoidRootPart

game:GetService('Debris'):AddItem(bv, 1) -- removes the BodyVelocity after a second
0
I don't recommend using Debris, as Debris uses the old :Remove() function instead of :Destroy(). Kyokamii 133 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

They're simply unit vectors which express the direction of faces. If they're not perpendicular to eachother, then you get some seriously wonky rendering, which you can see if you generate some inverted CFrames.

Answer this question