Quantcast
Channel: Questions in topic: "die"
Viewing all articles
Browse latest Browse all 115

code so if 1 enemy isnt killed every 4 seconds player dies?

$
0
0
how do I code it so if 1 enemy isn't killed at least every 4 seconds the player dies? not sure if this is right code to put here but this script is on all the enemies enemies are instantiated every second at least this is the enemys die script using UnityEngine; using System.Collections; [RequireComponent(typeof(AudioSource))] public class dedd : MonoBehaviour { public AudioClip pop1; public AudioClip boing; AudioSource audio; Animator anim; //reference to the animator component void Start() { audio = GetComponent(); //get reference to the animator component anim = GetComponent (); } void OnCollisionEnter2D(Collision2D other) //void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag == "Player" || other.gameObject.tag == "Wall" ) { // do something when we collide with "enemy1" OR "enemy2" anim.Play("fishded"); anim.SetTrigger("Die"); GetComponent ().Play (); audio.PlayOneShot(pop1, 0.7F); } else if (other.gameObject.tag == "bad" || other.gameObject.tag == "bad" ) { // do something else when we collide with "enemy3" OR "enemy4" anim.Play("fishded"); anim.SetTrigger("Die"); GetComponent ().Play (); audio.PlayOneShot(boing, 0.7F); } } }

Viewing all articles
Browse latest Browse all 115

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>