# CameraPathBezier.cs

public enum viewmodes

usercontrolled -rotations will be decided by the rotation of the contorl points

target – camera will always target a defined transform

mouselook – camera will have a mouse free look

followpath – camera will use the path to determine where to face – maintaining world up as up

reverseFollowpath – camera will use the path to determine where to face, looking back on the path

public Transform target;

The transform to target in viewmode.target

public Color lineColour;

The colour of the line in the Editor

public bool loop;

Should the path loop

public int numberOfControlPoints

The number of control points in the bezier curve

public int numberOfCurves

The number of curves in the bezier curve

public CameraPathBezierControlPoint[] controlPoints

Get an array of control points available in the curve.

Returns an array of CameraPathBezierControlPoint

public float storedTotalArcLength

The total arc length for the entire curve

This is useful to compute normalised curves

It’s generated in RecalculateStoredValues function

public float[] storedArcLengths

The array of arc lengths – each arc length is between two points

It’s generated in RecalculateStoredValues function

public void RecalculateStoredValues()

Calculate the stored values – for when the curve is modified or when we start

You shouldn’t need to call this function but just in case you might want to call it – here it is

We’re calculating the total arc length, individual arc lengths and a list of points specified by the storedArcLengthArraySize

The storedArcLengthFull is used to normalise the curve to attain a single speed thorughout the curve

public void DeletePoint(CameraPathBezierControlPoint deletePoint, bool destroy)

Delete a point in the path specified by the point itself.

deletePoint – component of the point

destroy – should the gameobject be destroyed?

public void DeletePoint(int index, bool destroy)

Delete a point in the path specified by the point index.

index – the index in point array to delete

destroy – should the gameobject be destoryed?

public void AddNewPoint()

Add a new point at the end of the array

public void AddNewPoint(int index)

Add a new control point specified by the index of where you want to place it.

public float GetNormalisedT(float t)

Normalise the time based on the curve point

Put in a time and it returns a time that will account for arc lengths

Useful to ensure that path is animated at a constant speed

t – time(0-1)

public Vector3 GetPathPosition(float t)

Sample a position on the entire curve based on time (0-1)

public Quaternion GetPathRotation(float t)

Sample a rotation on the entire curve based on time (0-1)

public float GetPathFOV(float t)

Sample a camera Field of View on the entire curve based on time (0-1)

public float GetPathPercentageAtPoint(CameraPathBezierControlPoint point)

Get the percentage based on the position of a point on the curve