title: Unity - Lerp rotations with foreach loop and with parent and child objects?
body: <p>I have 3 objects inside Unity that are 3 segments of an arm that is supposed to move. Each segment has 2 more empty game objects that are placed on the bottom and top of the segments (these are used as joints, which i wanna apply the rotations to). Inside the project these objects look like this:</p>
  <p><a href="https://i.stack.imgur.com/YQndD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YQndD.png" alt="enter image description here" /></a></p>
  <p>a1_1 is the main joint at the bottom of the arm and when this rotates everything should rotate with it (thats why its the parent). arm1, arm2 and arm3 are the segments. a2_1 and a3_1 are the two other joints that get rotations added.</p>
  <p>Now i have a .txt file with multiple lines of angles for each joint. I already have implemented a way to read this file and I'm using a foreach loop to read each line separately. However when I use the Quaternion.Lerp function it adds weird rotations and I dont really know why.</p>
  <p>All I want to do is for the joints to rotate to one specific point wait like 0.2 seconds and then rotate to the next point.</p>
  <pre><code>IEnumerator Run() {
      string[] tempAngles;
  
      foreach (string line in angleArray) {
          tempAngles = line.Split(' ');
  
          a1_1.rotation = Quaternion.Lerp(a1_1.rotation, Quaternion.Euler(90 - float.Parse(tempAngles[1]), float.Parse(tempAngles[0]), 0), Time.fixedDeltaTime * 1f);
          a2_1.rotation = Quaternion.Lerp(a2_1.rotation, Quaternion.Euler(180 - float.Parse(tempAngles[2]), 0, 0), Time.fixedDeltaTime * 1f);
          a3_1.rotation = Quaternion.Lerp(a3_1.rotation, Quaternion.Euler(float.Parse(tempAngles[3]) + 45, 0, 0), Time.fixedDeltaTime * 1f);
  
          //a1_1.rotation = a1_1.rotation * Quaternion.AngleAxis((90 - float.Parse(tempAngles[1]) * Time.fixedDeltaTime), Vector3.right);
  
          //a1_1.Rotate(90 - float.Parse(tempAngles[1]), float.Parse(tempAngles[0]), 0);
          //a2_1.Rotate(180 - float.Parse(tempAngles[2]), 0, 0);
          //a3_1.Rotate(180 - float.Parse(tempAngles[3]), 0, 0);
  
          yield return new WaitForSeconds(0.2f);
  
          print(&quot;done&quot;);
      }
  }
  </code></pre>
  <p>This is how the function looks so far. As you can see I have tried multiple different ways to add a rotation but none seem to work the way I want them to.</p>
  <p>This is how one line of angles look inside the txt file:</p>
  <pre><code>62.920341623781205 42.26008063439084 86.66333878215205 141.0765805834571
  </code></pre>
  <p>I split each angle where the spaces are and get 4 angles per step in the foreach loop.</p>