Question

In Unity I can handle circular motion around an object with a simple

transform.RotateAround(GameObject.Find("CubeTest").transform.position, Vector3.up, 20000*Time.deltaTime);

However, I want the object traveling in circular motion to approach this object whilst in orbit. Not entirely sure how to do this without screwing up.

Was it helpful?

Solution

GameObject cube = GameObject.Find("CubeTest");    
transform.LookAt(cube.transform);
transform.Translate(transform.forward * Time.deltaTime * approachSpeed);
transform.RotateAround(cube.transform.position, Vector3.up,20000*Time.deltaTime);

I think that could do as you want? It moves towards the rotation point gradually, then rotates, giving the appearance of a deteriorating orbit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top