Vector3

From Goodblox Wiki
Revision as of 11:21, 23 June 2020 by Pizzaboxer (talk | contribs) (Created page with "Vector3 handles inputs that need three values. It's not a hard concept once you get passed that. Vector3 has three values, an X ordinate, Y ordinate and Z ordinate. It repres...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Vector3 handles inputs that need three values. It's not a hard concept once you get passed that.

Vector3 has three values, an X ordinate, Y ordinate and Z ordinate. It represents a position in 3D space, just as a coordinate plane that you use in school, and can be in anything that needs to have a set of three values in order to function. (For example an object position, size, et cetera).


All [[Property|properties] are read-only. However, they can be changed via scripts.

Property Type Description
x number the x-coordinate
y number the y-coordinate
z number the z-coordinate
unit Vector3 a normalized copy of the vector
magnitude number the length of the vector


Vector3

Vector3 is three values. An X (Horizontal), a Y (Vertical), and a Z (Depth). Learning Vector3 is the first step to learning how to move a brick and/or a character.

Example:

A brick is on the position line of 0,10,0. It has three vectors (x=0, y=10, z=0). Now let's convert it to Vector3.

pos = Vector3.new(0,10,0)

You don't need to put it in a variable, it is just that a variable is much easier to use. I will teach you about "Vector3.new" later on. You see the term "Vector3.new", then 3 numbers seperated by commas inside two parentheses. The "0" is the x vector, the "10" is the y vector, and the other "0" is the z vector (Vector3.new(x, y, z).


Creating New Vectors

So now you want to teleport bricks? Here, we'll talk about "Vector3.new". When changing an object's position, you either use CFrame or "Vector3.new".

brick = game.Workspace.Part
brick.Position = Vector3.new(0,10,0) --Sets the part's x, y, and z coordinates.

In that example, we have Vector3.new(0,10,0), where X=0, Y=10, and Z=0.

See Also