Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

warning CS0108

Discussion in 'Scripting' started by XDKalabaZo, Aug 25, 2020.

  1. XDKalabaZo

    XDKalabaZo

    Joined:
    Aug 25, 2020
    Posts:
    14
    I need help I try to do this command and it does not leave me and I get this error

    Assets\Scripts\Jugador.cs(9,25): warning CS0108: 'Jugador.rigidbody2D' hides inherited member 'Component.rigidbody2D'. Use the new keyword if hiding was intended.


    Can somebody help me?
     

    Attached Files:

  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,735
    1) It's a warning, not an error. You can ignore it.
    2) The warning tells you exactly what to do to fix it: use the 'new' keyword.
    Code (csharp):
    1.  
    2.     private new Rigidbody2D rigidbody2D;
    3.  
     
    XDKalabaZo likes this.
  3. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,697
    Another option is to name your field something different that doesn't collide with a built-in unity property name.
     
  4. waxmaxgames

    waxmaxgames

    Joined:
    Mar 10, 2022
    Posts:
    2
    Thank you I help a lot!!!!