Vector3: Difference between revisions
>Mindraker feel free to alter this however you want... |
>Mindraker Vector3 |
||
Line 18: | Line 18: | ||
==Vector3== | |||
Vector3 defines position. Learning Vector3 is the first step to learning how to teleport a brick and/or a character. It is three vectors -- x, y, and z. | |||
Example: | |||
A brick is on the position line of 0,10,0. It has three vectors. Now let's convert it to Vector3. | |||
< | <pre> | ||
pos = Vector3.new(0,10,0) | |||
</pre> | |||
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. X goes left to right (horizontal), Y goes up and down (vertical), Z goes in and out (depth). | |||
===Creating New Vectors=== | |||
So now you want to teleport bricks. In the last segment, I told you about something called "Vector3.new". What it does is what it says, creates a new Vector3. When changing an object's position, you either use [[CFrame]] or "Vector3.new." | |||
<pre> | |||
brick = game.Workspace.Brick | |||
brick.Position = Vector3.new(0,10,0) | |||
</pre> | |||
First is the variable. Note what we are changing before the "=" sign, ".Position". Then we come to the "Vector3.new". Same as before, it is giving them new Vectors of x, y, and z, which is, in this case, a new position. | |||
== See Also == | |||
[[CFrame]] |
Revision as of 08:02, 4 November 2008
A Vector3 has three values, an X ordinate, Y ordinate and Z ordinate. It represents a position in 3D space, and can be in World coordinates, Object coordinates, or anything that needs to have a set of three values in order to function.
All properties are read-only.
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 defines position. Learning Vector3 is the first step to learning how to teleport a brick and/or a character. It is three vectors -- x, y, and z.
Example:
A brick is on the position line of 0,10,0. It has three vectors. 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. X goes left to right (horizontal), Y goes up and down (vertical), Z goes in and out (depth).
Creating New Vectors
So now you want to teleport bricks. In the last segment, I told you about something called "Vector3.new". What it does is what it says, creates a new Vector3. When changing an object's position, you either use CFrame or "Vector3.new."
brick = game.Workspace.Brick brick.Position = Vector3.new(0,10,0)
First is the variable. Note what we are changing before the "=" sign, ".Position". Then we come to the "Vector3.new". Same as before, it is giving them new Vectors of x, y, and z, which is, in this case, a new position.