...
If you want to manipulate the individual X, Y and Z values you first have to deconstruct the original vector. The instruction for this operation is get[axis]()
and is appended to the appropriate vector as seen in the examples before. With this operation a vector is split into its scalar components and can now be used for further vector calculations, e.g. multiplication with a scalar:
...
It expects three floating numbers (called an argument) and these values are represented by the new_velocity_[axis]
variables. RealFlow puts everything together to create a new vector that can be applied to the particle in the next step. You will soon learn how to set and apply such a vector or other new parameters to a particle or node. A vector does not necessarily need three completely new values and you can also mix different types. The following example contains a fixed float, a new result, and an existing vector from the particle’s original velocity.
...
You are also able to perform calculations directly within the new vector’s argument. That is a very good method to shorten your scripts, unless you have to use the new_velocity_[axis]
values somewhere else in your program. With this notation you can skip the assignment of three variables and save memory.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
new_velocity = Vector.new(velocity_x * 0.5, velocity_y / 2, velocity_z + 1.4) |
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
new_height = Vector.new(0.0, height * 2.5, 0.0) |