private void OnCollisionEnter2D(Collision2D collision) { if (collision.transform.CompareTag("Player")) { PlayerHealt playerHealt = collision.transform.GetComponent <PlayerHealt>(); playerHealt.TakeDamage(damageOnCollision); } }
// Use this for initialization void Awake () { //get agent agent = GetComponent<NavMeshAgent>(); //find player in scene igralec = GameObject.Find("Igralec"); playerHealt = igralec.GetComponent<PlayerHealt>(); trenutniTime = timeAttack; attackSound = GetComponent<AudioSource>(); }
private void Awake() { if (instance != null) { Debug.LogWarning("il y a plus d'une instance de PlayerHealt dans la scéne"); return; } instance = this; }