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);
}
}
}
↧