15 смерть противника

Первая часть

Донастраиваем мелочи

InputDamage.cs

using UnityEngine;
using System.Collections;

public class InputDamage : MonoBehaviour {
	public EnemyHealth hp;
	public int multipler;
	public void Hit(int damage)
	{
		hp.CurHealth -= damage*multipler;
		Debug.Log(damage*multipler);
	}
}

EnemyHealth.cs
using UnityEngine;
using System.Collections;

public class EnemyHealth : MonoBehaviour {
	public int CurHealth = 2;
	private bool die;
	public Transform[] elements;
	public Transform[] items;
	void Start () 
	{
	
	}
	void Update () 
	{
		if(CurHealth<=0&die==false)
		{
			die = true;
			Die();
		}
	}
	void Die()
	{
		foreach(Transform body in elements)
		{
			body.GetComponent<Rigidbody>().isKinematic = false;
		}
		transform.GetComponent<Animator>().enabled = false;
		Invoke("DropWeapon",0.2f);
	}
	void DropWeapon()
	{
		for(int i = 0; i<items.Length; i++)
		{
			items[i].parent = null;
			items[i].GetComponent<Rigidbody>().isKinematic = false;
		}
		transform.GetComponent<EnemyHealth>().enabled = false;
	}
}

Оставить комментарий