private void OnTriggerEnter(Collider other) { if (other.CompareTag("Player")) { //need to define playerHP in here on touch else null is thrown on player death playerHP = GameObject.FindGameObjectWithTag("Player").GetComponent <RainDamageHpHandler>(); //take 50 from player health playerHP.playerSize -= 50f; //call the rescale script playerHP.changeSize.Rescale(playerHP.playerSize, playerHP.maxSize); //destroy the droplet Destroy(gameObject); } if (other.CompareTag("Ground")) { Destroy(gameObject); } }
private void Start() { //the character handler is the component attached to our player //charH = this.GetComponent<healthbar>(); charHP = GetComponent <RainDamageHpHandler>(); #region Check if we have Key if (PlayerPrefs.HasKey("SpawnPoint")) { //then our checkpoint is equal to the game object that is named after our save file curCheckpoint = GameObject.Find(PlayerPrefs.GetString("SpawnPoint")); //our transform.position is equal to that of the checkpoint transform.position = curCheckpoint.transform.position; } else { curCheckpoint = GameObject.FindGameObjectWithTag("SpawnP"); } transform.position = curCheckpoint.transform.position; #endregion }
// Use this for initialization void Start() { playerRigid = GameObject.Find("Player").GetComponent <Rigidbody>(); dashDir = Vector3.zero; //set the initial dash direction to zero playerHP = GetComponent <RainDamageHpHandler>(); }
public float dripRate; //rate at which droplets will be created // Use this for initialization void Start() { dir = Vector3.down; playerHP = GameObject.FindGameObjectWithTag("Player").GetComponent <RainDamageHpHandler>(); isDrip = true; }