Skip to content

Instantly share code, notes, and snippets.

@kazuooooo
Created January 11, 2015 05:18
Show Gist options
  • Save kazuooooo/27072d888984c790d483 to your computer and use it in GitHub Desktop.
Save kazuooooo/27072d888984c790d483 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class UpDownAnimation : MonoBehaviour {
public float endtime;
public float topposition;
//x or y or z
public string direction;
// Use this for initialization
void Start () {
AnimationClip clip = new AnimationClip();
AnimationCurve curve = AnimationCurve.Linear(0f,0f,endtime,0f);
Keyframe key = new Keyframe(endtime/2,topposition);
curve.AddKey(key);
clip.SetCurve("",typeof(Transform),"localPosition."+direction,curve);
clip.wrapMode = WrapMode.Loop;
animation.AddClip(clip,"clip1");
animation.Play("clip1");
}
// Update is called once per frame
void Update () {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment