No Revisions Have Been Made To This Page
Can you suggest an edit for this page? Click Here
This section goes over the structure of the manual as well as an introduction to the GML Language and it's syntax.
This section introduces the types of numbers and basic variables in GML and their related functions.
The section covers the various assets involved in GameMaker: Studio and their related functions as well as Handling Input.
This section contains information about 2D Drawing, 3D Drawing, Shaders, Surfaces, and Views.
This section goes further into detail about the GML Language and more advanced functions like Networking, Data Structures, Physics, and more.
This section is a reference to the Platform Specific functions and methods available to you as well as integrating your game with Third Party Applications.
This section contains Debugging, Miscellaneous, and Obsolete function reference.
View :
Original

Community
Revision

Source
At some point when creating a game of any complexity you will
probably have to deal with vectors. They are used in
physics, in AI, in trigonometry and many other situations, but what
is a vector? Well, to put it simply, a vector is a directed
quantity. Let's start by looking at a 1 dimensional vector, which
is just the same as a single number, by drawing a numbered line
with an arrow starting at zero and ending at 5. This is the vector
a which is equal to 5 and if we draw another arrow starting
at the 5 and ending at the 8 we have vector b which is equal
to 3.
You should realise that it doesn't matter where a vector
starts, all that matters is how long it is and what direction it
goes in. So vector b starts at 5, is 3 units long and points
to the "right", making it identical to a vector starting at 0 and
going to 3. Now, you can also add these vectors together, by
putting the two vectors a and b end to end to get the
vector c which is equal to 8. What about negative numbers?
Well, if, in the above image, a vector that points to the "right"
corresponds to a positive number, you can see that a vector
pointing to the "left" would correspond to a negative number,
making a onedimensional vector nothing more than a signed (+/)
number. This explains the essential concept of a vector: only
length and direction ("left" or "right" in this case) count, not
position.
So, what about 2 dimensional vectors? Well, we can think of them as
consisting not just of "left" and "right, but "up" and "down"
too:
Now, those are not actually vectors yet as we still have to
reduce them down using their start and end coordinates. Looking at
vector a we can see it has a start coordinate of [2,2] and
an end coordinate of [4,3] and so to get the vector from this we
need to reduce it down by subtracting the end coordinates from the
start coordinates like this: [(x2x1), (y2y1)] = [(42), (32)] =
[2,1]. Let's do the same for vector b now: [(1.2 (3.2))
,(2.1  1.1)] = [2 ,1]. Notice something? Those two vectors are the
same! This is yet another demonstration that a vector has no
position, only direction and length, and we can draw those vectors
relative to each other around a local [0,0] axis:
This means that a 2D vector is defined by two values, an
x and a y position relative to the local [0,0] axis.
And what about 3D vectors? Well, they have the added dimension of
"depth" to contend with and would be calculated as positions
x, y and z around a local axis something like
this:
Can you suggest an edit for this page? Click Here
Does this page need better examples? Be the first to Submit
Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.
Do you have a question about this page? Ask it Here
To use this feature sign in with your Reddit account.