I making a score system and I’m trying to make it so that every time the player hits the ball the score goes up. The max score is 4. I’m doing this by deactivating the number and activating the next number. The problem is that when the player hits the ball the score automatically goes to 4. I’m trying to make it so that the score equals the amount of times you hit the ball.
Here is my code
void OnTriggerEnter(Collider other)
{
if (other.gameObject.name == “hit”)
{
v3_Forcex = t_Camera.forward;
v3_Forcey = t_Camera.up;
GetComponent<Rigidbody>().AddForce(v3_Forcex * f_Multiplierx, ForceMode.Force);
GetComponent<Rigidbody>().AddForce(v3_Forcey * f_Multipliery, ForceMode.Force);
GetComponent<Rigidbody>().useGravity = true;
if(defensescoring.activeInHierarchy)
{
playerscore0.SetActive(false);
playerscore1.SetActive(true);
}
if (defensescoring&playerscore1.activeInHierarchy)
{
playerscore1.SetActive(false);
playerscore2.SetActive(true);
}
if (defensescoring&playerscore2.activeInHierarchy)
{
playerscore2.SetActive(false);
playerscore3.SetActive(true);
}
if (defensescoring&playerscore3.activeInHierarchy)
{
playerscore3.SetActive(false);
playerscore4.SetActive(true);
}
}
}