By the default, Force Field processes up to 24 concurrent impacts in a Desktop and up to 6 in a Mobile version of the shader.

These are the steps to adjust number of simultaneous impacts processed:

  • Open Force Field Controller script (Forcefield.cs) and change interpolators value
  • Open Force Field Shader (Forcefield.shader) and find the line starting with #include “UnityCG.cging”

Notice two following lists of fixed4 _Pos_ and fixed _Pow_ declarations both starting with 0 indexes and ending with 23. Modify both lists, so they match to a number of interpolators you previously set in the Forcefield.Cs script.

For example, if you changed the interpolators from the default to a value of 8, you should set the indexes starting from 0 and end with 7.

Don’t be surprised by a number of variables required modifying by hand. Unfortunately passing an array wasn’t possible at the moment of Force Field release. Despite the fact, we look into available options considering Unity 5.4.0+ features and will be rolling new updates including even more simultaneous impacts shortly.

  • In shader, find a fragment section defining a number of interpolators and local array declarations. Adjust the interpolators value and array lengths according to a new number of impact points.
  • A few lines down bellow in the shader are two lists of pos[] and power[] array initialization. Adjust their names and indexes to correspond to the number of impacts you set earlier.
  • Lastly, go to the first line of the shader and change its name string to reflect the number of points then save the file by giving a different name. Switch back to the Editor and wait for it to compile.

Unity won’t tell you a word on the successful compilation. You can now switch to your modified shader in a drop-down list of a shield material.

Important

  • It is not recommended to increase the number of impact points in a Mobile shader due to platform limitations and a limited number of registers available on low-end platforms.
  • Raising a number of impact points too high will result in a performance decrease and should be used with caution.