Hi I am making a bowling game for college. I am trying to work on the score. Once the ball knocks down say 4 pins, I want the game to say, 'you got four" and restart so that the player can try knock down the rest. If they get a strike, I want eh game to say “You got a strike” and reload the level.
However currently, when the ball hits any pin, even only knocks down one pin the score goes straight to zero and the level restarts. Can anyone help please. Here is the script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class PinDetection : MonoBehaviour
{
public int pins = 10; //number of pins sper game
public Text scoreText;
// Use this for initialization
void Start () {
scoreText.text = "You Scored: " + scoreText.ToString ();
}
// Update is called once per frame
void Update ()
{
//Vector3 fwd = transform.TransformDirection(Vector3.forward);
if (transform.up.y < 0.5f)
{
Debug.Log("Yes");
pins--;
}
if (pins <= 0)
{
Debug.Log ("Strike");
Time.timeScale = .25f;
SceneManager.LoadScene (SceneManager.GetActiveScene ().buildIndex);
scoreText.text = "Strike";
}
else
if(pins>0 || pins<=10)
{
scoreText.text = "You scored" + pins;
}
}
}