I created Find Rock game but I have problem In replacing two object by rotating in center and when rotating finish stop rotating how can I do this?
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public GameObject[] obj;
public int[] Randomize = new int[2];
void Start(){
StartCoroutine (Delay ());
}
IEnumerator Delay(){
Randomize [0] = Random.Range (0, obj.Length);
Randomize [1] = Random.Range (0, obj.Length);
while (Randomize [0] == Randomize [1]) {
Randomize [0] = Random.Range (0, obj.Length);
}
yield return new WaitForSeconds (2);
obj [Randomize [0]].transform.rotation = Quaternion.Euler (new Vector3 (0, 0, 0));
obj [Randomize [1]].transform.rotation = Quaternion.Euler (new Vector3 (0, 0, 0));
StartCoroutine (Delay ());
}
void Update(){
if (obj [Randomize [0]].transform.rotation.eulerAngles.y < 90 || obj [Randomize [1]].transform.rotation.eulerAngles.y < 90) {
obj [Randomize [0]].transform.RotateAround (obj [Randomize [1]].transform.position, Vector3.up, Time.deltaTime * 100);
obj [Randomize [1]].transform.RotateAround (obj [Randomize [0]].transform.position, Vector3.up, Time.deltaTime * 100);
}
}
}
I can make this game but when rotating finish they aren't Directed.
How can I use mathf clamp RotateAround for stopping rotation?

