Hello, I hava created script to count goals, but the text is stucked on 0 even if i it should be 1 or more. Thanks for help :)
private int score1;
public Text score1Text;
// Use this for initialization
void Start()
{
score1 = 0;
SetScore1Text();
}
void OnCollisionEnter2D(Collision2D collisiongoal)
{
Goal1();
SetScore1Text();
score1 = score1 + 1;
}
void Goal1 ()
{
Goal.gameObject.SetActive(true);
GoalSound.Play();
ball.SetActive(false);
ball.transform.position = destination.position;
//Debug.Log("Goal!");
startgoal = true;
player1.gameObject.SetActive(false);
player2.gameObject.SetActive(false);
respawn = true;
}
void SetScore1Text()
{
score1Text.text = score1.ToString();
}
}
↧