Hello everybody,
I typed a really long question and realized it was boring, so this is a summary:
- My enemy has two hitpoints.
- if it dies it instantiates a particle system
- It can happen you only hit it once
- Enemy must be destroyed at some point if you failed to shoot it twice
- Enemy collides with my box which should destroy it, showing a different particle
- Because of collision, 1 hitpoint is subtracted, therefore now showing 2 particle systems
- Tried adding life on specific collision so it doesn’t show first particle system
- Doesn’t work
I attached this script to my enemy:
function OnCollisionEnter (collision : Collision){
life --;
if(life == 0){
Destroy(target);
Instantiate(RedBurst2, transform.position, transform.rotation);
Instantiate(plusone, transform.position, transform.rotation);
audio.PlayOneShot(AUW);
}
if(collision.gameObject.tag == "border"){
life++;
Destroy(zombie);
Instantiate(RedBurst, transform.position, transform.rotation);
Instantiate(minustwo, transform.position, transform.rotation);
}
}
I left out the vars, they speak for themselves. Can someone point out the error? I feel like it’s something really stupid.
Thanks!