Keyframe
Creates a keyframe with a Keyframe.weightedMode defaulting to WeightedMode.None.
Read time 2 minutesLast updated 4 days ago
Definition
- Type: Constructor
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
Keyframe(float, float)
Creates a keyframe with a Keyframe.weightedMode defaulting to WeightedMode.None.
public Keyframe(float time, float value)
Parameters
Examples
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 defaulting to WeightedMode.None.
public Keyframe(float time, float value, float inTangent, float outTangent)
Parameters
Keyframe.time of the Keyframe.
Keyframe.value of the Keyframe.
Keyframe.inTangent value for this Keyframe.
Keyframe.outTangent value for this Keyframe.
Examples
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 defaulting to WeightedMode.Both.
public Keyframe(float time, float value, float inTangent, float outTangent, float inWeight, float outWeight)
Parameters
Keyframe.time of the Keyframe.
Keyframe.value of the Keyframe.
Keyframe.inTangent value for this Keyframe.
Keyframe.outTangent value for this Keyframe.
Keyframe.inWeight value for this Keyframe.
Keyframe.outWeight value for this Keyframe.
Examples
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); }}