# 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.

## Definition

* **Type:** Class
* **Namespace:** [UnityEngine](/engine/6000.5/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule
* **Implements:** [IEquatable\<AnimationCurve>](https://learn.microsoft.com/dotnet/api/system.iequatable-1)

```csharp
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:

* Use [AnimationCurve.EaseInOut](/engine/6000.5/script-reference/unityengine/animationcurve/easeinout.md) for a curve that smoothly transitions from one value to another.
* Use [AnimationCurve.Linear](/engine/6000.5/script-reference/unityengine/animationcurve/linear.md) for a curve that linearly transitions from one value to another.
* Use [AnimationCurve.Constant](/engine/6000.5/script-reference/unityengine/animationcurve/constant.md) for a curve that holds a constant value over its duration.

To construct a complex AnimationCurve, use [AnimationCurve](/engine/6000.5/script-reference/unityengine/animationcurve/ctor.md) and [AnimationCurve.AddKey](/engine/6000.5/script-reference/unityengine/animationcurve/addkey.md).

Once constructed, use an AnimationCurve to animate the following properties:

* The [GameObject](/engine/6000.5/script-reference/unityengine/gameobject.md) position, rotation, scale, or component properties in an [AnimationClip](/engine/6000.5/script-reference/unityengine/animationclip.md).
* The properties of [ParticleSystem](/engine/6000.5/script-reference/unityengine/particlesystem.md) or [VisualEffect](/engine/6000.5/script-reference/unityengine/vfx/visualeffect.md).
* The properties of your own [MonoBehaviour](/engine/6000.5/script-reference/unityengine/monobehaviour.md) over time.

The following example illustrates how to use an AnimationCurve to gradually change the intensity of a [Light](/engine/6000.5/script-reference/unityengine/light.md).

## Examples

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

## Constructors

| Constructor                                                                                                                               | Description                                                       |
| ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
| [AnimationCurve()](/engine/6000.5/script-reference/unityengine/animationcurve/ctor.md#animationcurve\(\))                                 | Creates an empty animation curve.                                 |
| [AnimationCurve(UnityEngine.Keyframe\[\])](/engine/6000.5/script-reference/unityengine/animationcurve/ctor.md#animationcurve\(keyframe\)) | Creates an animation curve from an arbitrary number of keyframes. |

## Properties

| Property                                                                                   | Description                                               |
| ------------------------------------------------------------------------------------------ | --------------------------------------------------------- |
| [this\[\]](/engine/6000.5/script-reference/unityengine/animationcurve/item.md)             | Retrieves the key at index. (Read Only)                   |
| [keys](/engine/6000.5/script-reference/unityengine/animationcurve/keys.md)                 | All keys defined in the animation curve.                  |
| [length](/engine/6000.5/script-reference/unityengine/animationcurve/length.md)             | The number of keys in the curve. (Read Only)              |
| [postWrapMode](/engine/6000.5/script-reference/unityengine/animationcurve/postwrapmode.md) | The behaviour of the animation after the last keyframe.   |
| [preWrapMode](/engine/6000.5/script-reference/unityengine/animationcurve/prewrapmode.md)   | The behaviour of the animation before the first keyframe. |

## Methods

| Method                                                                                         | Description                                                                                                                                                                                                                                              |
| ---------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [AddKey](/engine/6000.5/script-reference/unityengine/animationcurve/addkey.md)                 | Add a new key to the curve.                                                                                                                                                                                                                              |
| [ClearKeys](/engine/6000.5/script-reference/unityengine/animationcurve/clearkeys.md)           | Erases all KeyFrame from this instance of the [AnimationCurve](/engine/6000.5/script-reference/unityengine/animationcurve.md).                                                                                                                           |
| [CopyFrom](/engine/6000.5/script-reference/unityengine/animationcurve/copyfrom.md)             | Copies the keys and properties of the specified [AnimationCurve](/engine/6000.5/script-reference/unityengine/animationcurve.md) object into this instance of the  [AnimationCurve](/engine/6000.5/script-reference/unityengine/animationcurve.md) class. |
| [Evaluate](/engine/6000.5/script-reference/unityengine/animationcurve/evaluate.md)             | Evaluate the curve at `time`.                                                                                                                                                                                                                            |
| [GetHashCode](/engine/6000.5/script-reference/unityengine/animationcurve/gethashcode.md)       | A HashCode for the animation curve, computed using all individual [Keyframe](/engine/6000.5/script-reference/unityengine/keyframe.md).                                                                                                                   |
| [GetKeys](/engine/6000.5/script-reference/unityengine/animationcurve/getkeys.md)               | Get all keys defined in the AnimationCurve.                                                                                                                                                                                                              |
| [MoveKey](/engine/6000.5/script-reference/unityengine/animationcurve/movekey.md)               | Moves the key at `index` to /key.time/ and /key.value/.                                                                                                                                                                                                  |
| [RemoveKey](/engine/6000.5/script-reference/unityengine/animationcurve/removekey.md)           | Removes a key.                                                                                                                                                                                                                                           |
| [SetKeys](/engine/6000.5/script-reference/unityengine/animationcurve/setkeys.md)               | Set all keys defined in the AnimationCurve.                                                                                                                                                                                                              |
| [SmoothTangents](/engine/6000.5/script-reference/unityengine/animationcurve/smoothtangents.md) | Smooth the in and out tangents of the keyframe at `index`.                                                                                                                                                                                               |

## Static Methods

| Method                                                                               | Description                                                                                                 |
| ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------- |
| [Constant](/engine/6000.5/script-reference/unityengine/animationcurve/constant.md)   | Creates a constant "curve" starting at `timeStart`, ending at `timeEnd`, and set to the value `value`.      |
| [EaseInOut](/engine/6000.5/script-reference/unityengine/animationcurve/easeinout.md) | Creates an ease-in and out curve starting at `timeStart`, `valueStart` and ending at `timeEnd`, `valueEnd`. |
| [Linear](/engine/6000.5/script-reference/unityengine/animationcurve/linear.md)       | A straight Line starting at `timeStart`, `valueStart` and ending at `timeEnd`, `valueEnd`.                  |
