// Use this for initialization void Start() { motor = gameObject.GetComponent <TankMotor>(); speedInfo = gameObject.GetComponent <TankData>(); ammunition = gameObject.GetComponent <TankData>().Ammo; noisemaker = gameObject.GetComponent <NoisemakerScript>(); }
// Use this for initialization void Start() { motor = gameObject.GetComponent <TankMotor>(); tankInfo_ = gameObject.GetComponent <TankData>(); originalLife = gameObject.GetComponent <TankData>().tankHealth; ammunition = gameObject.GetComponent <TankData>().Ammo; noisemaker = gameObject.GetComponent <NoisemakerScript>(); sfxAudio = GetComponent <AudioSource>(); }
public bool CanHear(GameObject target) { // If the target doesn't have a noisemaker, we can't hear them! NoisemakerScript targetNoiseMaker = target.GetComponent <NoisemakerScript>(); if (targetNoiseMaker == null) { return(false); } // If they do, check the distance -- if it is <= (noise volume * hearingDistance), then we can hear them! Transform playerTankTransform = target.GetComponent <Transform>(); if (Vector3.Distance(playerTankTransform.position, tankTF.position) <= targetNoiseMaker.volume * hearingDistance) { return(true); } // Otherwise, we can't hear them return(false); }