Exemple #1
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Player"))
     {
         player.Damage(1);
     }
 }
Exemple #2
0
 // Updates the boolean isGrounded by checking if the feet are colliding with an object that is ground
 private void UpdateYVelocity()
 {
     if (!_isJumpFrame && _isGrounded)
     {
         if (Math.Abs(_velocity.y) > fallDamageVelocityThreshold)
         {
             PlayerLife playerLife = gameObject.GetComponent <PlayerLife>();
             int        multiplier = Math.Abs((int)(_velocity.y / fallDamageVelocityThreshold) * 6);
             playerLife.Damage(multiplier);
         }
         _velocity.y = 0f;
     }
     else
     {
         _velocity.y -= gravity * Time.deltaTime;
     }
 }
Exemple #3
0
 private void DamagePlayer(PlayerLife astronautLives)
 {
     astronautLives.Damage(2);
 }