Search Unity

access variable

Discussion in 'Getting Started' started by eliot345, Oct 29, 2021.

  1. eliot345

    eliot345

    Joined:
    Oct 29, 2021
    Posts:
    1
    hello,
    The Player object has a public float named "size", and the Circle object has a public float named "size".I want to be able to increase size from the Circle, but I can't. The code is as follows:
    The code is as follows:
    Collision2D collisionEnter2D(void)
    {i
    "Player" if (coll.gameObject.name)
    {
    The size of this.GetComponent*playerMovement>() is equal to 1;
    }
    }
    I get a nullreferenceexception error whenever I run this code. Since I have no idea what code is, I would appreciate a brief explanation of Unity and C#.
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    This should help https://forum.unity.com/threads/help-in-assecing-variable.1187497/
     
  3. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512