void OnTriggerEnter2D(Collider2D other) { score = GetComponent <HUDScript> (); if (other.tag == "Player") { Back.SetActive(true); Button.SetActive(true); Kalah.SetActive(true); Score.SetActive(false); main.Stop(); end.Play(); //score.LastScore (); Time.timeScale = 0; //Debug.Break (); return; } else if (other.gameObject.transform.parent) { Destroy(other.gameObject.transform.parent.gameObject); } else { Destroy(other.gameObject); } }
// Update is called once per frame void Update() { tanah = Physics2D.OverlapCircle(deteksitanah.position, jangkauan, targetlayer); infonyawa.text = (" X ") + nyawa.ToString(); infokoin.text = (" X ") + koin.ToString(); if (ulang == true) { transform.position = mulai; ulang = false; } if (nyawa <= 0) { Destroy(gameObject); Kalah.SetActive(true); } if (finishline == 1) { Destroy(gameObject); Menang.SetActive(true); } if (tanah == true) { anim.SetBool("lompat", false); } else { anim.SetBool("lompat", true); } if (Input.GetKey(KeyCode.D) || (rightbutton == true)) { anim.SetBool("lari", true); transform.Translate(Vector2.right * kecepatan * Time.deltaTime); pindah = -1; } else if (Input.GetKey(KeyCode.A) || (leftbutton == true)) { anim.SetBool("lari", true); transform.Translate(Vector2.left * kecepatan * Time.deltaTime); pindah = 1; } else { anim.SetBool("lari", false); } if (pindah > 0 && !balik) { balikbadan(); } else if (pindah < 0 && balik) { balikbadan(); } }