private void OnTriggerEnter(Collider other) { FPSCameraAndMovController player = other.transform.GetComponent <FPSCameraAndMovController>(); if (player != null) { player.TakeDamage(1000); } }
private void OnTriggerEnter(Collider other) { Debug.Log("colisiono con " + other.name); //If the player is hit FPSCameraAndMovController player = other.transform.GetComponent <FPSCameraAndMovController>(); if (player != null) { player.TakeDamage(damage); impactPlayerSound.Play(other.transform); Destroy(this.gameObject); trayectorySound.Stop(FMOD.Studio.STOP_MODE.IMMEDIATE); } //Hits another enemy EnemyBehavior enemy = other.transform.GetComponent <EnemyBehavior>(); if (enemy != null) { enemy.TakeDamage(damage); impactPlayerSound.Play(other.transform); Destroy(this.gameObject); trayectorySound.Stop(FMOD.Studio.STOP_MODE.IMMEDIATE); } //Hits a turret TurretBehavior turret = other.transform.GetComponent <TurretBehavior>(); if (turret != null) { turret.TakeDamage(damage); impactPlayerSound.Play(other.transform); Destroy(this.gameObject); trayectorySound.Stop(FMOD.Studio.STOP_MODE.IMMEDIATE); } //Bounce if possible if (other.gameObject.layer.Equals(14) && isBounceable) { //Debug.Log("rebote"); //Bounce in the opposite direction and double velocity if we are in blademode and we swing playerGO.GetComponent <FPSCameraAndMovController>().PlayBounce(); GetComponent <Rigidbody>().velocity = -GetComponent <Rigidbody>().velocity * 2.0f; } //If collides with anything else else { impactNoneSound.Play(other.transform); Destroy(this.gameObject); trayectorySound.Stop(FMOD.Studio.STOP_MODE.IMMEDIATE); } }