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

What is upvector and rightvector used for?

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


1 comment

0

because directional unit vectors aren't meant for use for positions

2 answers

✓ Accepted answer

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

1 comment

0

I don't recommend using Debris, as Debris uses the old :Remove() function instead of :Destroy().

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.

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