this is 2d game and javascript
what im looking for is to “on collision” with player the enemy gets killed, but the player can(if he wants to) over kill the enemy,
in other words-- if player hits enemy 2nd time and 3rd the enemy will get blown up more. I want 6 possible /allowed collisions per enemy.
So on 1st collision enemy dies,
On 2nd collision enemy explodes more
3rd collision enemy blows up to pieces, 4th smaller pieces-5th more smaller pieces etc
I know the images are up to me so you guys cant help with that -
what I need help with is how to code and allow on the 1st collision this animation(death1)/ or image shows, on 2nd collision (death2) shows on 3rd collision death3 shows etc
how do you code this? please be specific im new here and would like to know exact instructions to follow if anyt
below is the working on collision 1st death
PLEASE KEEP IN MIND I HAVE AND UNDERSTAND THE ON COLLISION Death 1ST One… I just don’t know how to do allow, the 2nd 3rd etc…
keep in mind the enemy will fade out after about 4-5 seconds no matter what so if player doesn’t overkill the enemy to death 2 an deth3 etc enemy is set to disappear
var animator : Animator;
var Boom: AudioClip;
var ded: AnimationClip;
var hit: AudioClip;
var ko: AnimationClip;
function Start () {
animator = GetComponent("Animator");
animation.clip = ded;
animation.clip = ko;
audio.clip = Boom;
audio.clip = hit;
}
function OnCollisionEnter2D(coll : Collision2D) {
if (coll.gameObject.tag == "Enemy") {
animator.SetBool("dead", true);
Debug.Log("Player collision detected");
animator.SetBool("Fire1", true);
audio.PlayOneShot(Boom);
audio.PlayOneShot(hit);
}
else {
animator.SetBool("Fire1", false);
}
}
function SetFire1(value: boolean) {
Fire1 = value;
animator.SetBool("Fire1", value);
}