Question by
yusi_bjk · Jan 10, 2019 at 11:12 AM ·
scenescene change
I want the score to remain as the scene changes.
The score disappears after the scene changes. I dont want him to disappear. can you help me ?
private Rigidbody2D myRigidbody;
private Animator myAnimator;
private int skor;
public Text toplamSkor;
[SerializeField]
private float hiz;
private bool sagaBak;
[SerializeField]
private AudioSource altinSes;
// Use this for initialization
void Start () {
sagaBak = true;
skor = 0;
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);
}
} void SkorAyarla(int count) { toplamSkor.text = count.ToString (); }
}
Comment