MoveObject

Author: Eric Haines (Eric5h5)

Description
Simple routines for moving an object from point A to point B (either over a specified time, or at a certain rate) and rotating by a given number of degrees over time. For more advanced animation, try AniMate, Tween, or iTween.

Usage
Put this script in your Standard Assets/Scripts folder; this way it can be easily used from C# or Boo. The script should be named "MoveObject". The script must be attached to some object in the scene, such as an empty object used for game manager scripts. You then use the coroutines by calling MoveObject.use.Translation or MoveObject.use.Rotation. Since they're coroutines, just call them when needed; no need for Update.

function Translation (transform : Transform, startPosition : Vector3, endPosition : Vector3, value : float, moveType : MoveType) : IEnumerator

Moves transform from startPosition to endPosition. value is either the number of seconds it takes to complete the translation (if moveType is set to MoveType.Time) or the number of units per second that the transform will move at (if moveType is set to MoveType.Speed).

function Translation (transform : Transform, endPosition : Vector3, value : float, moveType : MoveType) : IEnumerator

Same as above, except the starting position is whatever position the transform happens to be at when you start the routine, and endPosition is relative to the starting position. So using Vector3.right*2.0 would move the transform 2 units to the right.

function Rotation (transform : Transform, degrees : Vector3, time : float) : IEnumerator

Rotates transform by degrees over time seconds. The degrees is a Vector3 so you can specify the axis. i.e., Vector3(0.0, 0.0, 180.0) or Vector3.forward*180.0 would rotate 180 degrees along the Z axis.