Unity error CS0029: Cannot implicitly convert type int' to
bool’
I keep getting this error while trying to add a animation trigger to my C# script:
using UnityEngine;
using System.Collections;
public class Score : MonoBehaviour {
static int score = 0;
static int highScore = 0;
Animator animator;
static public void AddPoint() {
score++;
if (score > highScore) {
highScore = score;
}
}
void Start() {
score = 0;
highScore = PlayerPrefs.GetInt ("highscore", 0); {
if (highScore = 20)
animator.SetTrigger ("Char2");
}
}
void OnDestroy() {
PlayerPrefs.SetInt ("highscore", highScore);
}
void Update () {
guiText.text = "Score: " + score + "
Highscore: " + highScore;
}
}
What i have here is a score system and i’m trying to make it so when the highScore is 20, it triggers an animation. But this line:
if (highScore = 20)
animator.SetTrigger ("Char2");
Keeps giving me the Unity error CS0029: Cannot implicitly convert type int' to
bool’
I’ve looked around for a solution but it’s confusing me further (I’m pretty new to Unity and C# so bare with me)
So my question is, how do i go about making this thing work so that when the highScore reaches 20, the animation is triggered?