// Start is called before the first frame update void Start() { pScript = gameObject.GetComponent <D_playerScript>(); touchScript = gameObject.GetComponent <PlayerTouchScript>(); rb2d = gameObject.GetComponent <Rigidbody2D>(); HPText = GameObject.Find("PlayerUI").transform.Find("HPText").gameObject; HPBar = GameObject.Find("PlayerUI").transform.Find("HealthBG").gameObject; }
void Awake() { if (current == null) { current = this; } else { Destroy(this.gameObject); return; } if (SceneManager.GetActiveScene().name == "TutorialScene") { return; } DontDestroyOnLoad(this.gameObject); }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == null) { //do nothing } if (collision.gameObject.tag == "Player") { if (collision.transform.GetComponent <D_playerScript>() != null) { D_playerScript player = collision.transform.GetComponent <D_playerScript>(); player.increaseHealth(healthIncrease); audioManager.instance.playClip(deathSound); this.gameObject.SetActive(false); } } else if (collision.gameObject.tag == "Wall") { this.gameObject.SetActive(false); } }