Is that line pass score to score keeper script?

Ave all
I got method from lecture:
void OnTriggerEnter2D(Collider2D collider){
Projectile missile = collider.gameObject.GetComponent();
if (missile) {
hitPoints -= missile.GetDamage();
missile.Hit();
if (hitPoints <= 0) {
Destroy(gameObject);
scoreKeeper.ScorePoints(scoreValue);
}
}
}

And i’m not sure how last line work:
scoreKeeper.ScorePoints(scoreValue);

In pass score to scorekeeper script (scoreKeeper = GameObject.Find(“ScorePoints”).GetComponent():wink:
?

Your ScoreKeeper script should have a public ScorePoints method in it. The method declaration should be something like “public void ScorePoints (int points)”.

Privacy & Terms