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

[Solved]

Discussion in 'Scripting' started by GhulamJewel, Jun 20, 2014.

  1. GhulamJewel

    GhulamJewel

    Joined:
    May 23, 2014
    Posts:
    351
    [Solved]
     
    Last edited: Apr 19, 2015
  2. zaxvax

    zaxvax

    Joined:
    Jun 9, 2012
    Posts:
    220
    9. private SpriteRenderer ren;damagedEnemy // Reference to the sprite renderer.
     
  3. GhulamJewel

    GhulamJewel

    Joined:
    May 23, 2014
    Posts:
    351
    thanks! I removed that bit

    but now I get a warning saying

    "d:\Unity\New Unity Project\Assets\Scripts\PlayerHealthScript.cs(25,25): Warning CS0649: Field 'PlayerHealthScript.ren' is never assigned to, and will always have its default value null (CS0649) (Assembly-CSharp)"

    I think this is what is stopping the script from function properly? just want a sprite to render on certain HP but nothing happens! Thanks.
     
  4. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    No, it's just a warning.

    It's warning you that since this variable is never used, it's basically wasting memory space.
     
  5. GhulamJewel

    GhulamJewel

    Joined:
    May 23, 2014
    Posts:
    351
    thanks for reply so how would I correct this script? is there any mistakes anyone can see it get it to work? thank you.
     
  6. GhulamJewel

    GhulamJewel

    Joined:
    May 23, 2014
    Posts:
    351
    Never mind I fixed it!! for some strange reason I just change the private SpriteRenderer to public...and the warning went away and it worked.