Search Unity

Object reference not set to an instance of an object.

Discussion in 'Scripting' started by Tropicaliste, Jun 5, 2018.

  1. Tropicaliste

    Tropicaliste

    Joined:
    Dec 2, 2014
    Posts:
    1
    So i'm getting this error message when i'm trying to move my player from another script.

    Code (CSharp):
    1.     public void Roll1 ()
    2.     {
    3.         int Dice1 = Random.Range(1, 6);
    4.         int Dice2 = Random.Range(1, 6);
    5.         int DiceTotal = Dice1 + Dice2;
    6.         Playerr.transform.Translate(DiceTotal, 0, 0);
    7.     }
    8.     GameObject Playerr;
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,188
    Do you have a value assigned to Playerr?

    That's what your error means, nothing is assigned to the variable.
     
    Joe-Censored likes this.