As a further extension to the fixed speed sim I decided to give particles the concept of velocity and the ability to generate currents in their wake to pull or disrupt passing particles. These are implemented by having a 200 by 200 multidimensional array of vector 2’s. After a particle updates its position to its new position it adds to the relevant cell a proportion of its current velocity. Whilst this addition is very small as many particles travel an area this can generate a significant vector within the array.
All particles when updating their position from their steering velocity then also add a proportion of this vector to their speed. The proportions both deposited and copied from the array are carefully balanced to prevent a runaway affect causing extreme vectors to be generated.
Two other mechanics are at play on the grid, firstly the vectors are diffused from a grid cell to all adjacent cells every tick which causes the currents to bleed out from their current position and affect more cells, imagine ripples on the surface of a pond.
Secondly all the vectors are reduced every tick by a certain percentage (1%) to reduce the strength of the generated currents over time. This is also important to prevent the grid becoming saturated in high strength vectors.
An example of this running with the debug overlay showing the vectors and their strengths can be seen in the last tweet in this series. (bottom of the page)
A full explanation and walk through will be created in a future blog