Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


AnimationCurve

Represents the variation of a value over time. AnimationCurves are typically used to animate the value of Component properties in AnimationClip, but you can use them to dynamically drive any float value.
Read time 2 minutesLast updated 5 days ago

Definition

public class AnimationCurve : IEquatable<AnimationCurve>

Remarks

The AnimationCurve class is a core component of Unity's Animation System.
To construct a simple AnimationCurve through code, use one of the following static utility methods:
To construct a complex AnimationCurve, use AnimationCurve and AnimationCurve.AddKey.
Once constructed, use an AnimationCurve to animate the following properties:
The following example illustrates how to use an AnimationCurve to gradually change the intensity of a Light.

Examples

{code Tests/EditModeAndPlayModeTests/Animation/Assets/DocumentationExamples/AnimationCurve-class-example.cs}

Constructors

Constructor

Description

AnimationCurve()Creates an empty animation curve.
AnimationCurve(UnityEngine.Keyframe[])Creates an animation curve from an arbitrary number of keyframes.

Properties

Property

Description

this[]Retrieves the key at index. (Read Only)
keysAll keys defined in the animation curve.
lengthThe number of keys in the curve. (Read Only)
postWrapModeThe behaviour of the animation after the last keyframe.
preWrapModeThe behaviour of the animation before the first keyframe.

Methods

Method

Description

AddKeyAdd a new key to the curve.
ClearKeysErases all KeyFrame from this instance of the AnimationCurve.
CopyFromCopies the keys and properties of the specified AnimationCurve object into this instance of the AnimationCurve class.
EvaluateEvaluate the curve at
time
.
GetHashCodeA HashCode for the animation curve, computed using all individual Keyframe.
GetKeysGet all keys defined in the AnimationCurve.
MoveKeyMoves the key at
index
to /key.time/ and /key.value/.
RemoveKeyRemoves a key.
SetKeysSet all keys defined in the AnimationCurve.
SmoothTangentsSmooth the in and out tangents of the keyframe at
index
.

Static Methods

Method

Description

ConstantCreates a constant "curve" starting at
timeStart
, ending at
timeEnd
, and set to the value
value
.
EaseInOutCreates an ease-in and out curve starting at
timeStart
,
valueStart
and ending at
timeEnd
,
valueEnd
.
LinearA straight Line starting at
timeStart
,
valueStart
and ending at
timeEnd
,
valueEnd
.