Quantcast
Channel: Questions in topic: "up"
Viewing all articles
Browse latest Browse all 104

How to make object moving forward while looping up and down

$
0
0
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; } }

Viewing all articles
Browse latest Browse all 104

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>