Convex MeshCollider Issue

Since version update 2.4, the Controller script has the capability to get past the limitation of a non-convex MeshCollider with a non-kinematic Rigid body introduced with Unity 5.0.

This feature requires a few changes in your typical workflow such as rearrangement of the components and disabling MeshColliders. To understand the specifics of such changes, we will have a closer look at the example involved in the Weapon_Range_RigidBody_Fix scene.

To start out, the parent object “ship” contains two sets of subobjects representing various parts such as engines, sensors, etc. One set of meshes used to render the actual geometry of the ship and the other is the Force Field surface covering particular components.

The key elements reside on parent “ship” including Rigid body and Force Field Controller. Notice the Controller’s Field slots stacked with shields marked with a green rectangle on the screenshot. This is one of the important differences along with the shield surface setup.

Looking at the “engine” child under the Shield game object first thing to be aware of is the absence of Force Field Controller. When using “Fix Rigidbody” option, you no longer have to put the Controller on each shield instance, but instead, attach one instance to your top most object. That said, the Controller will automatically detach the slotted shield pieces and will carry them along.

One more thing to keep in mind is the MeshCollider component should be disabled on each shield element the hierarchy. It is a necessary step that will help bypass the errors thrown by Unity into the console.

To wrap up this chapter let us highlight the most important steps in non-convex mesh and non-kinematic rigid body workflow:

  • Keep a SINGLE Force Field Controller instance on the top most object

  • Fill in the “Field” slots with shield elements contained within the parent

  • Avoid adding a Force Field Controller to shield objects

  • Keep MeshColliders disabled

Rigidbody Collisions

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

OnCollisionEnter, OnCollisionStay and OnCollisionExit

        void OnCollisionEnter(Collision collisionInfo)
            if (CollisionEnter)
                foreach (ContactPoint contact in collisionInfo.contacts)
        void OnCollisionStay(Collision collisionInfo)
            if (CollisionStay)
                foreach (ContactPoint contact in collisionInfo.contacts)
        void OnCollisionExit(Collision collisionInfo)
            if (CollisionExit)
                foreach (ContactPoint contact in collisionInfo.contacts)

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:


  • 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:

Last updated