Force Field is proficient at handling Rigid body collision events sent by Unity Engine in the following methods:

OnCollisionEnter, OnCollisionStay and OnCollisionExit

136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
        // COLLISIONS EVENTS
        void OnCollisionEnter(Collision collisionInfo)
        {
            if (CollisionEnter)
                foreach (ContactPoint contact in collisionInfo.contacts)
                    OnHit(contact.point);
        }
 
        void OnCollisionStay(Collision collisionInfo)
        {
            if (CollisionStay)
                foreach (ContactPoint contact in collisionInfo.contacts)
                    OnHit(contact.point);
        }
 
        void OnCollisionExit(Collision collisionInfo)
        {
            if (CollisionExit)
                foreach (ContactPoint contact in collisionInfo.contacts)
                    OnHit(contact.point);
        }

The collision data sent with these events is redirected to the shader throughout the OnHit() method. It is pretty similar to a ray casting technique mainly used to invoke the effect from a script.

Response to collision events can be switched using checkboxes in the Controller component:

Important

  • Collision events are only sent if one of the colliders also has a non­kinematic rigid body attached.
  • If there is a reason not to use Rigid Body vs Force Field collisions it is best to comment corresponding sections in Controller script to avoid unnecessary amounts of data sent into these methods.

To get more on collision events and rigid bodies, refer to the official manual pages: