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:

   protected abstract void OnCantMove (T component)
   protected override void Start ()
   {
    //Get a component reference to the Player's animator component
    animator = GetComponent();

    //Get the current food point total stored in GameManager.instance between levels.
    food = GameManager.instance.playerFoodPoints;

    //Set the foodText to reflect the current player food total.
    foodText.text = "Food: " + food;

    //Call the Start function of the MovingObject base class.
    base.Start ();
   }