- Home /
Question by
crystark · May 18, 2017 at 11:04 AM ·
move an objectupdowntowards
How to make object moving forward while looping up and down
Hi, guy! I'm new to Unity. I've created this script to make object looping up and down. How can I move the object to the -x axis. Something like a bird tries to avoid a beam that moves up, down and movs toward to the bird. Thanks everyone.
public class updowntest : MonoBehaviour {
public float delta;
public float speed;
private Vector3 startPos;
void Start () {
startPos = transform.position;
}
void Update () {
Vector3 v = startPos;
v.y += delta * Mathf.Sin(Time.time * speed);
transform.position = v;
}
}
Comment