How to make object do certain movements repeatedly?

Hey guys,

So I would like to make a Gameobject(Sprite) move up and down slightly repeatedly. Up, then down, up then down, etc.

How do I do this? Does Unity have some type of “Action” system where I can use some type of sequence action and then have it move up and down?

Thanks guys.

Just did some searching around and for this, you can use itween for this or any tweener. Just in case someone else is wondering.

using UnityEngine;
using System.Collections;

public class platform : MonoBehaviour {

    public Vector3 p1;
    public Vector3 p2;
    public float speed;
 
    void Update () {
        transform.position = Vector3.Lerp (p1, p2, Mathf.PingPong (Time.time*speed, 1f));
    }
}

but it can be not smooth, so you should use other timer instead time.time. Something like MyTimer += Time.deltaTime

You can also use the mechanim system to animate it in a loop.