# Keyframe

> Creates a keyframe with a Keyframe.weightedMode defaulting to WeightedMode.None.

## Definition

* **Type:** Constructor
* **Namespace:** [UnityEngine](/engine/6000.5/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

## Keyframe(float, float)

Creates a keyframe with a [Keyframe.weightedMode](/engine/6000.5/script-reference/unityengine/keyframe/weightedmode.md) defaulting to [WeightedMode.None](/engine/6000.5/script-reference/unityengine/weightedmode/none.md).

```csharp
public Keyframe(float time, float value)
```

### Parameters

**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): [Keyframe.time](/engine/6000.5/script-reference/unityengine/keyframe/time.md) of the Keyframe.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): [Keyframe.value](/engine/6000.5/script-reference/unityengine/keyframe/value.md) of the Keyframe.

### Examples

```csharp
using UnityEngine;

public class Example : MonoBehaviour
{
    // Make a GameObject follow a sine function.
    // Over the X and Y axis.

    AnimationCurve anim;
    Keyframe[] ks;

    void Start()
    {
        ks = new Keyframe[50];
        for (var i = 0; i < ks.Length; i++)
        {
            ks[i] = new Keyframe(i, Mathf.Sin(i));
        }
        anim = new AnimationCurve(ks);
    }

    void Update()
    {
        transform.position = new Vector3(Time.time, anim.Evaluate(Time.time), 0);
    }
}
```

## Keyframe(float, float, float, float)

Creates a keyframe with a [Keyframe.weightedMode](/engine/6000.5/script-reference/unityengine/keyframe/weightedmode.md) defaulting to [WeightedMode.None](/engine/6000.5/script-reference/unityengine/weightedmode/none.md).

```csharp
public Keyframe(float time, float value, float inTangent, float outTangent)
```

### Parameters

**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): [Keyframe.time](/engine/6000.5/script-reference/unityengine/keyframe/time.md) of the Keyframe.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): [Keyframe.value](/engine/6000.5/script-reference/unityengine/keyframe/value.md) of the Keyframe.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): [Keyframe.inTangent](/engine/6000.5/script-reference/unityengine/keyframe/intangent.md) value for this Keyframe.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): [Keyframe.outTangent](/engine/6000.5/script-reference/unityengine/keyframe/outtangent.md) value for this Keyframe.

### Examples

```csharp
using UnityEngine;

public class Example : MonoBehaviour
{
    // Make a GameObject follow a sine function.
    // Over the X and Y axis.

    AnimationCurve anim;
    Keyframe[] ks;

    void Start()
    {
        ks = new Keyframe[50];
        for (var i = 0; i < ks.Length; i++)
        {
            ks[i] = new Keyframe(i, Mathf.Sin(i), 90f, 90f);
        }
        anim = new AnimationCurve(ks);
    }

    void Update()
    {
        transform.position = new Vector3(Time.time, anim.Evaluate(Time.time), 0);
    }
}
```

## Keyframe(float, float, float, float, float, float)

Creates a keyframe with a [Keyframe.weightedMode](/engine/6000.5/script-reference/unityengine/keyframe/weightedmode.md) defaulting to [WeightedMode.Both](/engine/6000.5/script-reference/unityengine/weightedmode/both.md).

```csharp
public Keyframe(float time, float value, float inTangent, float outTangent, float inWeight, float outWeight)
```

### Parameters

**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): [Keyframe.time](/engine/6000.5/script-reference/unityengine/keyframe/time.md) of the Keyframe.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): [Keyframe.value](/engine/6000.5/script-reference/unityengine/keyframe/value.md) of the Keyframe.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): [Keyframe.inTangent](/engine/6000.5/script-reference/unityengine/keyframe/intangent.md) value for this Keyframe.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): [Keyframe.outTangent](/engine/6000.5/script-reference/unityengine/keyframe/outtangent.md) value for this Keyframe.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): [Keyframe.inWeight](/engine/6000.5/script-reference/unityengine/keyframe/inweight.md) value for this Keyframe.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): [Keyframe.outWeight](/engine/6000.5/script-reference/unityengine/keyframe/outweight.md) value for this Keyframe.

### Examples

```csharp
using UnityEngine;

public class Example : MonoBehaviour
{
    // Make a GameObject follow a sine function.
    // Over the X and Y axis.

    AnimationCurve anim;
    Keyframe[] ks;

    void Start()
    {
        ks = new Keyframe[50];
        for (var i = 0; i < ks.Length; i++)
        {
            ks[i] = new Keyframe(i, Mathf.Sin(i), 0f, 0f, 0f, 0f);
        }
        anim = new AnimationCurve(ks);
    }

    void Update()
    {
        transform.position = new Vector3(Time.time, anim.Evaluate(Time.time), 0f);
    }
}
```
