Implementing the Clamp and UI in Unity

In my previous post, I implemented the 3D model and control logic for a telescopic rotating arm with Lerp() to animate the rods and visualize the behavior.  In the code update, I changed Lerp() to RotateTowards() and MoveTowards() in a Coroutine to make the movement seem more mechanical versus the spring effect of simple Lerp() and introduced on-screen buttons to supplement keyboard input.

I modified the model to have a clamp, using simple boolean difference to cut through the original cylinder and then separated the halves.


The key step is to move the pivot to the end connected to the arm to rotate as a clamp.


Updated the original model to have the Left and Right Clamp objects and renamed the Rods (Arms) to count from 0 (zero) –to be code consistent. I created a new script to handle Clamp behaviors instead of adding the functionality on the Telescopic script since I will have other Clamps connected to other devices.


The script commands are exposed as public methods that can be invoked from a master control script (I wanted to name it program as in MCP but it’s called a script in this world)


Added buttons to simplify controls and they can invoke the public script methods.


The sample WebGL app is posted at:


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