title: How can I wait for the object to end spinning and then play the animation?
body: <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using UnityEngine.Events;
  
  public class RoboSphereWindowBreakInteraction : MonoBehaviour
  {
      public Transform target;
      public InteractableObjects interactableObjects;
      public AudioClip audioClip;
      public float speed;
  
      private bool hasStarted = false;
      private Animator anim;
  
      void Update()
      {
          if ((Input.GetKeyDown(KeyCode.B) || (hasStarted == true)))
          {
              float step = speed * Time.deltaTime; // calculate distance to move
              transform.position = Vector3.MoveTowards(transform.position, target.position, step);
  
              hasStarted = true;
          }
      }
  
      private void OnTriggerEnter(Collider other)
      {
          if (other.gameObject.name == "Square 1")
          {
              GetComponent&lt;Rigidbody&gt;().isKinematic = false;
              hasStarted = false;
              Destroy(GameObject.Find("Wall_Window_Long_03"));
          }
      }
  
      public void ActivateRoboSphere()
      {
          foreach(Transform child in transform)
          {
              if(child.name == "Camera")
              {
                  RepositionCamera(child);
              }
          }
  
          anim = GetComponent&lt;Animator&gt;();
          anim.enabled = true;
  
          StartCoroutine(PlayAudio());
      }
  
      private void RepositionCamera(Transform camera)
      {
          var Eyes = GameObject.Find("eyeDome");
  
          camera.position = Eyes.transform.position + Eyes.transform.forward;
          camera.LookAt(Eyes.transform);
          camera.GetComponent&lt;Camera&gt;().enabled = true;
      }
  
      IEnumerator PlayAudio()
      {
          AudioSource audio = GetComponent&lt;AudioSource&gt;();
  
          audio.clip = audioClip;
          audio.Play();
          yield return new WaitForSeconds(audio.clip.length);
  
          var rotation = Quaternion.LookRotation(target.position - transform.position);
          StartCoroutine(Spin(3f, rotation));
  
          anim.SetBool("Roll_Anim", true);
      }
  
      IEnumerator Spin(float lerpTime, Quaternion rotation)
      {
          float elapsedTime = 0f;
  
          while (elapsedTime &lt;= lerpTime)
          {
              transform.rotation = Quaternion.Slerp(transform.rotation, rotation, elapsedTime / lerpTime);
              elapsedTime += Time.deltaTime;
              yield return null;
          }
      }
  }
  </code></pre>
  
  <p>But when the animation start the object spin but not facing the target at least not the target I wanted.</p>
  
  <p>The object the sphere start rotating facing the window(in the screenshot in the background in the  top scene view) but then it's changing the facing back facing the camera(the camera that is child of the transform).</p>
  
  <p>The method ActivateRoboSphere call RepositionCamera and ActivateRoboSphere is being called once when clicking the mouse in a on click event.</p>
  
  <p>But for some reason when the object is playing the "Roll_Anim" animation it's facing the camera again and not the window the target.</p>
  
  <p>I marked the window target where it should face at with red square in the screenshot :</p>
  
  <p><a href="https://i.stack.imgur.com/r55YT.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/r55YT.jpg" alt="Facing the robosphere child camera on the left and not the window target marked with red square"></a></p>