// Update is called once per frame void Update() { if (Input.GetKey(KeyCode.F)) { powCon.Add(pow); } }
public void OnTriggerEnter(Collider other) { // variable to store other object's PowerupController - if it has one PowerUpController powCon = other.GetComponent <PowerUpController>(); // If the other object has a PowerupController if (powCon != null) { // Add the powerup powCon.Add(powerup); if (FeedbackAudioClip != null) { AudioSource.PlayClipAtPoint(FeedbackAudioClip, gameObject.GetComponent <Transform>().position, 1.0f); } // Destroy this pickup GetComponent <MeshRenderer>().enabled = false; StartCoroutine(Respawn(powerup)); } IEnumerator Respawn(PowerUp power) { yield return(new WaitForSeconds(RespawnTime)); GetComponent <MeshRenderer>().enabled = true; powerup.duration = 5; } }
void OnTriggerEnter(Collider other) { //Get the powerup controller on the colliding object PowerUpController powCon = other.gameObject.GetComponent <PowerUpController>(); //Check to see if it has a Powerup Controller //It it HAS a powerup controller if (powCon != null) { //Add power up to its controller powCon.Add(powerup); //Null check for feedback audio if (feedbackAudioClip != null) { //Play feedback sound at location at volume //TODO: Adjust volume based on settings AudioSource.PlayClipAtPoint(feedbackAudioClip, tf.position, 1.0f); } //set isSpawned in PickupSpawner mySpawner.isSpawned = false; //Destroy this game object Destroy(this.gameObject); } }
// Update is called once per frame void Update() { //Add cheat power up on F key if (Input.GetKeyDown(KeyCode.F)) { powCon.Add(CheatPowerUp); } }
public void OnTriggerEnter(Collider other) { PowerUpController powcon = other.GetComponent <PowerUpController>(); //variable to store the other objects power up if (powcon != null) // if the object has a power up { powcon.Add(powerup); //add to you if (feedback != null) { AudioSource.PlayClipAtPoint(feedback, tf.position, 1.0f); } Destroy(gameObject); //destroy the object } }
private void OnTriggerEnter(Collider other) { PowerUpController puController = other.gameObject.GetComponent <PowerUpController>(); Transform tran = other.gameObject.GetComponent <Transform>(); if (puController != null) { puController.Add(modData); if (feedback != null) { AudioSource.PlayClipAtPoint(feedback, Vector3.zero, 5.0f); } Destroy(gameObject); } }
//OnTriggerEnter public void OnTriggerEnter(Collider collider) { //Get PowerupController PowerUpController powCon = collider.GetComponent <PowerUpController> (); //if trigger has a powCon Script (it's a tank) if (powCon != null) { powCon.Add(powerup); //Play feedback if (feedback != null) { AudioSource.PlayClipAtPoint(feedback, tf.position, PlayerPrefs.GetFloat("FXVol")); } Destroy(this.transform.parent.gameObject); powerupsInGame.DecrementNumInGame(); } }
private void OnTriggerEnter(Collider other) { PowerUpController powerupController = other.gameObject.GetComponent <PowerUpController>(); if (powerupController != null) { // Add the powerup to the powerup controller powerupController.Add(powerup); // Play the sound effect if one exists. if (soundEffect != null) { // Use PlayClipAtPoint to play audio when you're destroying the source of that audio. AudioSource.PlayClipAtPoint(soundEffect, transform.position); } // Destroy this gameobject because it has been collected. Destroy(this.gameObject); } }