Attractors
Besides emitters a particle system can also contain attractors. An attractor attracts the particles (or pushes them away). A particle system can have multiple attractors. You are though recommended to use few of these because they will slow down the processing of the particles. An attractor has the following properties:- x,y indicate the position of the attractor.
- force indicates the attracting force of the attractor. How the force acts on the particles depends on the following parameters.
- dist indicates the maximal distance at which the attractor has effect. Only particles closer that this distance to the attractor will be attracted.
- kind indicates the kind of attractor. The following values exist
- ps_force_constant indicates that the force is constant independent of the distance.
- ps_force_linear indicates a linearly growing force. At the maximal distance the force is 0 while at the position of the attractor it attains the given value.
- ps_force_quadratic indicates that the force grows quadratic.
- additive indicates whether the force is added to the speed and direction in each step (true) or only applied to the position of the particle (false). When additive the particle will accelerate towards the attractor while with a non-additive force it will move there with constant speed.
The following functions exist to define attractors. Note that each of them gets the index of the particle system to which it belongs as a first argument.
part_attractor_create(ps) Creates a new attractor in the given particle system. It returns the index of the attractor. This index must be used in all calls below to set the properties of the attractor.
part_attractor_destroy(ps,ind) Destroys attractor ind in the particle system. Call this if you don't need it anymore to save space.
part_attractor_destroy_all(ps) Destroys all attractors in the particle system that have been created.
part_attractor_exists(ps,ind) Returns whether the indicated attractor exists in the particle system.
part_attractor_clear(ps,ind) Clears the attractor ind to its default settings.
part_attractor_position(ps,ind,x,y) Sets the position of attractor ind to (x,y).
part_attractor_force(ps,ind,force,dist,kind,aditive) Sets the force parameters of attractor ind.