Other Ways to Create Vectors
Useful methods of getting vectors in Skript.
Last updated
Useful methods of getting vectors in Skript.
Last updated
This expression creates a vector using a cylindrical shape, where the vector is made from the center of a cylinder to a point on the side at a specific height.
The syntax is as follows:
Now of course, similar setup to the other expressions:
And if you were to visualize the created vector:
This is a bit of a niche but simple expression, but it has uses so it will be discussed anyway.
All this expression does is return a vector with the same components as the input location:
And some examples:
In the second example, the returned vector will become vector(0, 64, 0)
.
And as you may have guessed, this does not make the returned value a location, it will be a vector. Which means that the other data ( such as world, yaw, and pitch ) will be lost.
Again this is a bit of a niche but simple expression, but it has uses so it will be discussed anyway.
This may come off as no surprise, but this expression does the opposite of the previous, it will take the components of the vector, a world, and optionally a yaw and pitch and turn it into a location:
If the yaw and pitch are not included, then both will be defaulted to 0.
This expression simply gets the vector from one location to another. In other words, can be thought of just subtracting the components from the first location by the second.
The returned vector "points" from the first location to the second, and the length being the distance between the two locations.
And can be used like:
If it still seems confusing, you can implement what this expression does by getting the vectors from both locations and then subtracting them:
But it's still recommended to use the built in expression for this, both for performance and cleanliness reasons.
The velocity of something represents its speed and direction in meters per tick, which in Skript is represented as a vector ( yay ). Currently in Minecraft only entities have velocities.
Along with being able to get the velocity of an entity, we are able to modify it:
Having the vector vector(1, 0, 0)
for example, as your velocity does not mean that you will be travelling exactly 1 meter per tick in the X direction, as the game has other calculations it performs when moving the entity, such as gravity and drag.
This expression, as the same suggests, returns a random vector. More specifically, it returns a random unit vector where each component is a random number between -1
and 1
, this expression is preferred when you need random vectors instead of generating the numbers yourself as the components.
And the the code is as simple as you can get...
As expected, every time that code is ran, {_v}
will be a different vector every time.
In 2.6.4, this expression isn't fully random. The 3 random numbers have a bias towards pointing to the corners of a cube, like towards 1, 1, 1. This is fixed in 2.7.