How do unity2d I make my game start “3-2-1 go”?
Hello I'm new at unity and I have a problem. I want my game to start after "3-2-1 go" as getting started. help me.
My Player Script :
using UnityEngine; using UnityEngine.UI;
public class Player : MonoBehaviour {
private Rigidbody2D myRigidbody;
private Animator myAnimator;
private int skor;
public Text toplamSkor;
public Text highScore;
[SerializeField]
private float hiz;
private bool sagaBak;
[SerializeField]
private AudioSource altinSes;
// Use this for initialization
void Start () {
sagaBak = true;
skor = 0;
highScore.text = PlayerPrefs.GetInt ("HighScore", 0).ToString();
myRigidbody = GetComponent<Rigidbody2D> ();
myAnimator = GetComponent<Animator> ();
}
// Update is called once per frame
void Update () {
float yatay = Input.GetAxis ("Horizontal");
TemelHareketler (yatay);
YonCevir (yatay);
}
private void TemelHareketler (float yatay){
myRigidbody.velocity = new Vector2 (yatay *hiz, myRigidbody.velocity.y);
myAnimator.SetFloat ("KarakterHizi", Mathf.Abs (yatay));
}
private void YonCevir (float yatay)
{
if (yatay > 0 && !sagaBak || yatay < 0 && sagaBak) {
sagaBak = !sagaBak;
Vector3 yon = transform.localScale;
yon.x *= -1;
transform.localScale = yon;
}
}
void OnCollisionEnter2D(Collision2D other) {
if (other.gameObject.tag == "altin") {
other.gameObject.SetActive (false);
altinSes.Play ();
skor = skor + 1;
SkorAyarla (skor);
if (skor > PlayerPrefs.GetInt ("HighScore", 0))
{
PlayerPrefs.SetInt ("HighScore", skor);
highScore.text = skor.ToString();
}
}
} void SkorAyarla(int count) { toplamSkor.text = count.ToString (); }
public void Reset (){
PlayerPrefs.DeleteAll ();
}
}
Comment