**Description:**

The following example shows the default Every Step Update script with detailed comments.

**Can Be
Used With:**

Used by PF_Source as default Every Step Update script.

**Effect:**

The script modifies particle speed and direction, causing particles to follow a spiral path:

*
Example:*

--Get the current particle system executing the script

pf_node_current = particleFlow.scriptRunner()

--In case the current particle system is a valid node

if (pf_node_current != undefined) then

(

--Get the total number of particles

count = pf_node_current.NumParticles()

--Loop from 1 to the number of particles

for i in 1 to count do

(

--Set the particle index in the container to the current i value.

--This makes the i-th particle in the container the current one:

pf_node_current.particleIndex = i

--Get the age of the particle, multiply by 5 and use as angle

--to define the particle speed

--Decreasing the constant 5 will slow down the rotation

--Increasing the constant will speed up the rotation

age = 5*pf_node_current.particleAge

--Calculate the speed of the particle using the

--function of the circle.

--Info: In general, a circle can be drawn using an Angle

--going from 0 to 2*Pi and the following functions for X and Y:

--X = CenterX+Radius*Cos(Angle)

--Y = CenterY+Radius*Sin(Angle)

--In our case, CenterX and CenterY are 0, Radius is 0.05 units,

--and Angle is based on the Age of the particles (see above).

--Changing the constant 0.05 will change the radius of the path.

--Changing the –0.05 (Z speed) will change the height of the spiral.

pf_node_current.particleSpeed = [0.05*cos(age), 0.05*sin(age), -0.05]

)--end i loop

)--end if

**See
also**