Feb. 19th, 2018
Creating a Basic Cam Model – Maya
Using Maya, I was able to create a very basic cam mechanism using a basic cylinder as the main body, and moving a few of the edges symmetrically to create a more interesting shape for the follower to follow as it rotated.
Colliders for Cam in Unity
Placing Colliders
- Use Capsule Collider for main body of Cam (turned sideways, the body of the capsule collider works well as a cylinder collider)
- This capsule collider has its radius set to that of the Cam main body, and its height can be adjusted to fit the thickness
- Create gameObject – cube
- Remove components: Mesh Renderer and Mesh Filter (leaves cube’s collider: this collider has more flexibility for more complex designs)
- Set this as a child of the original game object of choice (the gear model in our case)
- This was rotated at a 45 degree angle and moved to fit the sharp tear-shaped location of the Cam
Setting Up Cam-Follower System
- Cam Constraints: Frezze Position – x,y,z; Freeze Rotation – x,y
- The Cam was given a script to rotate it about its Y-axis
- Cam rotation is used to physically drive the follower
- Follower Constraints: Frezze Position – x,z; Freeze Rotation – x,y,z
- Follower was also affected by gravity, to help physically drive it to follow the cam
The follower for this cam-follower system is just a generic Unity cube game Object for now, with a basic box collider. This setup appeared to work well for this basic cam-follower mechanism. There was a bit of a difference in the way this cam was imported into Unity as opposed to the gear, which will need looked into. Its polySurface, which contains the mesh of the object, is a separate and child object of the actual “Cam_Basic_Unity” export.
Driving Gear Mechanisms in Unity with Physics Engine
The following video shows the cam-follower system in action.