IEnumerator Speed(Collider player) { GetComponent <MeshRenderer>().enabled = false; GetComponent <Collider>().enabled = false; MobilePlayer stats = player.GetComponent <MobilePlayer>(); stats.speed *= multiplier; audio.Play(); yield return(new WaitForSeconds(duration)); stats.speed /= multiplier; Destroy(gameObject); }
public void TakeDamage(float damage) { Debug.LogFormat("ZZZ Destructable take damage {0} to {1}", damage.ToString(), gameObject.name.ToString()); health -= damage; // If player, hurt player/kill player MobilePlayer mobilePlayer = GetComponent <MobilePlayer>(); if (mobilePlayer != null) { mobilePlayer.TakeDamage(damage); } // If environment, kill environment }