C
C#14mo 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
Thinker14mo ago
$unity
MRW419
MRW419OP14mo ago
I thought this was problem with my script I think it's a different issue
MRW419
MRW419OP14mo ago
No description
SinFluxx
SinFluxx14mo ago
Like above you'll be best off asking in the Unity discord
Accord
Accord14mo 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.
Want results from more Discord servers?
Add your server