Copying and Pasting cs Code

In cs, like in almost any computer programming language, reading data from a file can be tricky. You add extra lines of code to tell the computer what to do. Sometimes you can copy and paste these lines from other peoples’ code.

For example, you can follow the pattern in this listing:

     public void Update()
     {
         // We get 10 updates per sec. sometimes a few less or one or two more, depending on variation of lag.
         // Due to that we want to reach the correct position in a little over 100ms. This way, we usually avoid a stop.
         // Lerp() gets a fraction value between 0 and 1. This is how far we went from A to B.
         //
         // Our fraction variable would reach 1 in 100ms if we multiply deltaTime by 10.
         // We want it to take a bit longer, so we multiply with 9 instead.

         fraction = fraction + Time.deltaTime * 9;
         transform.localPosition = Vector3.Lerp(onUpdatePos, latestCorrectPos, fraction); // set our pos between A and B
     }