Game Development Reference
In-Depth Information
Cameras and curves
For cut-scenes, menu backgrounds, or simpler camera fly-throughs, you might just
need the camera to travel roughly in a straight line that allows some curvature and
fluctuation in speed as the camera moves using a smooth-in and smooth-out motion.
This means that the camera picks up speed at the beginning and slowly drops
in speed towards the end of the path. To achieve this, you can use a prescripted
animation via Unity's animation editor, or you can use animation curves, which
offer a high degree of flexibility and control over object transformations across
time, as shown here:
Moving cameras with animation curves
To create a camera control script that allows you to control object speed and
motion over time, including curved motion and smoothing or damping of speed,
the following code sample 5-12 can be used:
//-----------------------------
using UnityEngine;
using System.Collections;
//-----------------------------
public class CameraMover : MonoBehaviour
{
//-----------------------------
//Total time for animation
public float TotalTime = 5.0f;
//Total Distance to move on each axis
public float TotalDistance = 30.0f;
//Curves for motion
 
Search WWH ::




Custom Search