C
C#9mo 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);
}


}


}
}
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);
}


}


}
}
No description
6 Replies
Thinker
Thinker9mo ago
$unity
MRW419
MRW4199mo ago
I thought this was problem with my script I think it's a different issue
MRW419
MRW4199mo ago
No description
SinFluxx
SinFluxx9mo ago
Like above you'll be best off asking in the Unity discord
Accord
Accord9mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.