Ok, so the statements are all correct. You just added one too many ;
behind the if-statement. If-Statements do not need a ;
since the {...}
ends the statements.
The correct code is hence:
if (other.gameObject.CompareTag("Player")) //no semicolon here
{
Debug.Log("collision w/ " + other.gameObject.name);
theScore += 50;
scoreText.GetComponent<Text>().text = "SCORE: " + theScore;
Destroy(gameObject);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…