C#C
C#3y ago
MRW419

❔ Why can't I place my animation onmy score script?

It worked last Friday but when I came back it didn't save. I'm trying to fix it but now I can't add the animator to my score script and I don't know why


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class Score : MonoBehaviour
{
    public Text scoreDisplay;
    public int threeStars = 3;
    public int twoStars = 5;
    public Animator scoreAnimator;
    public int nextLevel = 0;

    public void EndLevel()
    {
        Cannon cannon = FindObjectOfType<Cannon>();

        if (cannon)
        {
            int numProjectiles = cannon.numProjectiles;

            if (numProjectiles < threeStars)
            {
                print("Three Stars!");
                scoreDisplay.text = "Three Stars!";
                scoreAnimator.SetInteger("Stars", 3);
            }
            else if (numProjectiles < twoStars)
            {
                print("Two Stars!");
                scoreDisplay.text = "Two Stars!";
                scoreAnimator.SetInteger("Stars", 2);
            }
            else 
            {
                print("One Star!");
                scoreDisplay.text = "One Star! Try Again!";
                scoreAnimator.SetInteger("Stars", 1);
            }
            
            
        }

        
    }
}
image.png
Was this page helpful?