I’m making an Arkanoid game and I have this simple code to increment a score variable when my ball collides with the bricks. However when i print out the variable in doesnt seem to change. Can someone help me, im still a beginner.
int score;
void Start(){
score = 0;
}
// Simply delete the bricks that the ball collides with
void OnCollisionEnter2D(Collision2D coll){
if (coll.gameObject.name == "Ball") {
score++;
Debug.Log (score);
Destroy(gameObject); //Destroys the brick
}
}