A collection of 3D constraints - simple behaviors you can use like building blocks. If you have used a 3D animation package, such as Maya, Max or Softimage, you will recognize the basic constraint types, but UnityConstraints takes these further to specifically aid Unity game development by offering standardized solutions to common behaviors. For example, you won't want to code your own 'look at' solution ever again.
UnityConstraints are light-weight and efficient and designed for performance in even the most demanding situations.
Most Constraints Now Update Live in the Editor even when the game isn't playing, making classic "rigging" possible!
All components are namespaced to protect your project from Type collisions.
Now comes with an example file for each constraint type.
Included Constraints
(See the user documentation for more detailed information)
- Transform Constraint (position, rotation, scale) - Choose to constraint any combination of position, rotation or scale to easily create different behaviors.
- Smooth Transform Constraint (position, rotation, scale) - Works just like the Transform Constraint . except instead of being locked on the target 100%, this constraint will interpolate towards the target over-time.
- LookAt Constraint - Look at another object along any axis of your choice. You can also choose which axis you want to use as the 'up' axis/vector and optionally set a secondary object for the 'up' axis to point at.
- Smooth LookAt Constraint - Similar to a LookAt Constraint except that it interpolates (rotates) toward the target. This has a smoothing effect so if the target moves really fast, or a new target is added, the constrainted object will not snap instantly to the new rotation. This is great for the heads of characters and gun turrets. In fact, this constraint is the only thing making our towers aim at targets in the Tower Defense we are developing. We give this constraint a target whenever there is an update, and the constraint does the rest!
- Billboard Constraint - A type of 'LookAt' constraint which keeps an object facing the camera along a parallel axis. This is great for keeping a sprite facing the camera without distortion as the camera rotates. If you don't supply a target, this constraint will default to the main camera. Optionally billboard vertically only (rotates on Y axis only) for use with sprites representing objects such as trees and bushes.
- World to 2D Camera Constraint - Make objects in a 2D camera space follow objects in the game world. This is excellent for working with sprite-based GUI systems such as nGUI and EZGUI or for custom effects like cros-shairs and flairs!
- Turntable Constraint - Simply makes the constrained object rotate along its local 'up' axis at a given speed. No target object is used in this constraint but so many games (including ours) require a simple rotating object that we included this. It is built on the UnityConstraints framework so it takes advantage of all the solid features mentioned below.
this, simply add a Transform Constraint, set to only position, and a Billboard constraint....that's it!
The Unity Constraints Frame-Work
- Uses Co-routines Instead of Update() for maximum performance control and zero overhead beyond their basic funcitonlity. You shouldn't worry about performance when adding UnityConstraints .
- Modes: Off, Once, Constrain - 'Constrain' mode will run every frame but there are times where you only need a constraint to run once; to align rather than constrain. This is great, for example, if you want to spawn
a sprite with a flash animation that really only needs to face the
camera for an instant. 'Align' and 'off' use zero performance overhead after the first frame thanks to co-routine management.
- "No Target" Modes: Including "Set By Script" which allows you to take control of a constraint. For example, instead of giving a SmoothLookAt constraint a target, set its position directly using a Vector3 to make it turn towards an arbitrary point in space.
- Easy On/Off -You can change the mode to turn a constraint on and off, or you can just enable and disable the component, or entire GameObject. It all works, handled internally with no performance issues.
- Extensible - UnityConstraints is an Object-Oriented framework that adds a consistent way of accessing and using constraints and makes creating new constraints easy. If you need anything, or just have an idea for a new constraint, please visit our forums and let us know! You will find a link at the top of every page of this web site.
Demo Video (Available in HD)
Transform Constraint