title: Unity / Photon - Multiplayer
body: <p>Background: I'm working on a small multiplayer game, where multiple cars are under a GameObject (which is used in the car selection menu), but in a part of the tutorial I'm working, it's mentioned as player controls shall be under if (view.IsMine) { my control code here} but I'm receiving the following error: NullReferenceException: Object reference not set to an instance of an object
  CarControl.Update () (at Assets/Code/CarControl.cs:30)</p>
  <p>The script I'm using is:</p>
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using Photon.Pun;
  
  public class CarControl : MonoBehaviour
  {
      PhotonView view;
  
      public float MoveSpeed = 50;
      public float MaxSpeed = 15;
      public float Drag = 0.98f;
      public float SteerAngle = 20;
      public float Traction = 1;
  
      private Vector3 MoveForce;
  
      void Gravity()
      {
          Physics.gravity = new Vector3(0, -1.0F, 0);
      }
  
      private void Start()
      {
          view = GetComponent&lt;PhotonView&gt;();
      }
  
      void Update()
      {
          if (view.IsMine)
          {
              //Moving
              MoveForce += transform.forward * MoveSpeed * Input.GetAxis(&quot;Vertical&quot;) * Time.deltaTime;
              transform.position += MoveForce * Time.deltaTime;
  
              //Steering
              float steerInput = Input.GetAxis(&quot;Horizontal&quot;);
              transform.Rotate(Vector3.up * steerInput * MoveForce.magnitude * SteerAngle * Time.deltaTime);
  
              //Drag and speed limit
              MoveForce *= Drag;
              MoveForce = Vector3.ClampMagnitude(MoveForce, MaxSpeed);
  
              //Traction
              Debug.DrawRay(transform.position, MoveForce.normalized * 3);
              Debug.DrawRay(transform.position, transform.forward * 3, Color.blue);
              MoveForce = Vector3.Lerp(MoveForce.normalized, transform.forward, Traction * Time.deltaTime) * MoveForce.magnitude;
          }
      }
  }
  </code></pre>