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 OnTriggerEnter(Collider other)
     {
         // it's ridiculously easy to switch teams. you only have to make sure you do it for your own characters
         // (this trigger is called on all clients, when a user's character enters the trigger...)

         // find a PhotonView and check if the character "isMine". Only then, set this client's player-team.
         PhotonView otherPv = other.GetComponent();
         if (otherPv != null && otherPv.isMine)
         {
             PhotonNetwork.player.SetTeam(this.TeamToSwitchTo);
         }
     }