Search Unity

Object reference not set to an instance of an object referring to if Statement

Discussion in 'Scripting' started by tomXGames, Jun 24, 2019.

  1. tomXGames

    tomXGames

    Joined:
    Apr 23, 2019
    Posts:
    4
    Hi!

    The error message "Object reference not set to an instance of an object" is referring to this piece of code:

    Code (CSharp):
    1.         if (MobileInput.Instance.swipeLeft || Input.GetKeyDown(KeyCode.LeftArrow))
    2.         {
    3.             MoveLane(false);
    4.         }
    Can anyone help me here?

    tomX
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,187
    If MobileInput is your own script, chances are Instance has no value.
     
    palex-nx likes this.