So I have the following code : void Start() { LevelManager = FindObjectOfType<levelManager>(); soundEffect = FindObjectOfType<SoundEffect>(); position = transform.position; myAnim = GetComponent<Animator>(); spriteR = GetComponent<SpriteRenderer>(); } public void UpdateCarSprite() { switch (LevelManager.healthCount) { case 3: return; case 2: spriteR.sprite = DentedCar; return; case 1: spriteR.sprite = SuperDentedCar; return; case 0: spriteR.sprite = null; return; default: spriteR.sprite = FullCarHealth; break; } } The sprite renderer temporarily changes the sprite but by the next frame it is changed back to the original fullcarhealth sprite. I do not understand what is up.
In your code, change the return; keywords to break; instead. I'm not certain this is your issue but whatever happens suggests that in the next frame the default value is the choice being made. Is the healthCount becoming something other than given in the options (i.e something other than 0, 1, 2, or 3)? Code (CSharp): switch (LevelManager.healthCount) { case 3: break; case 2: spriteR.sprite = DentedCar; break; case 1: spriteR.sprite = SuperDentedCar; break; case 0: spriteR.sprite = null; break; default: spriteR.sprite = FullCarHealth; break; }