I'm making a Unity 3D bowling game but haven't figured out how to tally up the number of pins knocked after the ball has hit.
I have tried noticing when the pins rotation has changed but it doesn't seem to work.
I am destroying the ball and that is how the level ends so and instantiates the next level.
Below is the code I added to the pin. Do I need to have an on-collision event for this script to be called. Currently my console just prints "Pin is Standing" the whole time.
public class Pin : MonoBehaviour {
public int score;
public void Update()
{
TallyScore();
}
public void TallyScore()
{
//checking if the pin is standing up (if it's not, the pin's rotation will be not 0)
if (transform.rotation.x < 1 && transform.rotation.z < 1)
{
Debug.Log("Pin is standing");
}
else
{
//pin is knocked over
score++;
Debug.Log(score);
}
}
public int getScore()
{
return score;
}
}
i'd leave it at true. But in the end I'm not really sure what's better here. If training isn't tooo slow i'd just try both :D
– Captain_Pineapple