Hello world For as long as I can remember, theres always been this 1 snippet of code that I couldn't quite figure out (except maybe once, but I forgot how I got it). Say we want an object to move towards another one with a constant vector (say 20) in 2-dimensional space. How do you do this? We want to find Distance of x,y , and we are given x,y, and the constant vector with which we want to proceed (20 in this case). Even if theres a built in method for this, I would like to know what the formula(s) are for peace of mind
Code (CSharp): public GameObject target; transform.position = Vector3.MoveTowards(transform.position, target.position); Or you could do this i guess... Code (CSharp): void Update () { this.transform.position += Vector3.left * Time.deltaTime; this.transform.position += Vector3.right* Time.deltaTime; this.transform.position += Vector3.up * Time.deltaTime; }