// Update is called once per frame void Update() { if (keyboardOrAndroidInputs) { if (Input.GetKeyDown(KeyCode.H)) { attack = true; } } else { if (CrossPlatformInputManager.GetButtonDown("Attack")) { attack = true; } } if (attack) { animator.SetTrigger("hit"); audioSource.PlayOneShot(soundHit); // play hit sound if (EnemyCollision && dinoGroundHealth.getCurrentHealth() > 0) { dinoGroundHealth.DinoHurt(damageAttack); } attack = false; } }
public void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.CompareTag("GroundDino")) { dinoGroundHealth = other.gameObject.GetComponent <GroundEnemiesAI>(); dinoGroundHealth.DinoHurt(damageAttack); //On détruit le projectile a la collision avec l'ennemi Destroy(gameObject); } }