inside your if statement you are disabling the block from running after 1 iteration resulting in barely any movement, try to comment out disabling the booleans so it can run
if (MustOrbit && !IsOrbited) {
//Rotate all models around X,Y,Z axe
if (cube != null)
transform.RotateAround (center.position, axis, rotationSpeed * Time.deltaTime);
desiredPosition = (transform.position - center.position).normalized * radius + center.position;
transform.position = Vector3.MoveTowards(transform.position, desiredPosition, Time.deltaTime * radiusSpeed);
// IsOrbited = true;
// MustOrbit = false;
}
to reset the x,y,z on your model in your start get the starting xyz as a vector3
public Vector3 reset;
in Start()
void Start () {
cube = GameObject.FindWithTag("MarkerObject");
center = cube.transform;
transform.position = (transform.position - center.position).normalized * radius + center.position;
radius = 2.0f;
reset = transform.position;
}
then onGUI()
void OnGUI() {
GUI.matrix = Matrix4x4.TRS(Vector2.zero, Quaternion.identity,new Vector3(Screen.width / 480.0f, Screen.height / 320.0f, 1));
if (!btnTexture2) {
Debug.LogError("Please assign a texture on the inspector");
return;
}
//GUI.color = new Color(0,0,0,0);
//GUI.backgroundColor = Color.clear;
if (GUI.Button(new Rect(10, 10, 120, 30), btnTexture2))
if (!IsOrbited) {
MustOrbit = true;
}
}
if(GUI.Button(new Rect(Screen.width*5/6,Screen.height*5/6,Screen.width/6,Screen.height/6),"reset")){
transform.position = reset;
}