Handling Object Interaction in the Unity Scene with Triggers

After implementing a telescoping arm and clamp covered in the previous post, Implementing the Clamp and UI in Unity — the next step is to interact with objects in the scene. The core design is based on the command-action pattern just like in the prototype discussed in Prototyping Robotic Factory Game in Unity3D. The scene is in 3D so position tracking is more complicated that simple bounding rectangles, I use triggers with compound colliders to detect object interactions.

I create another set of simple 3D models in Maya to represent the interactive and receiver objects. The interactive object is a simple cylinder that fits inside the clamp and the receiver a bucket.

Clamp3-01-ActionBase

The models are imported in Unity with applicable colliders and control scripts. The interactive object is configured with a simple Box Collider set as Triggers.

Clamp3-02-ActionObject

The receiver object is setup with the collider in the upper section where the object is expected to be placed for processing.

Clamp3-03-ActionBaseUnity

The Telescoping Arm Rods and Clamp Structure are setup with compound colliders per GameObject to follow the transform / positions as they are moved and to handle collisions with other objects.

Clamp3-04-ClampColliders

Following is the view of the arm and clamp folded with the colliders matching position.

Clamp3-05-ClampColliders2

The sample WebGL app is posted at:

http://orbitalfoundry.com/WebGL/Factory1C/index.html

Clamp3-06-WebGL

For questions, comments or contact – follow/message me on Twitter @rlozada