Exemplo n.º 1
0
        public void Hurt(int amount)
        {
            // Only hurt once invincibility runs out.
            if (_timeSinceHurt <= _invincibilityTime)
            {
                return;
            }
            _timeSinceHurt = 0;
            _hurtParticles.Play();
            _screenShake.SetDuration(1);
            ChangeHealth(-amount);

            var newPosition = _respawnPoint.position;

            newPosition.z      = 0;
            transform.position = newPosition;
            // Reset y velocity.
            _rb.velocity = Vector2.right * _rb.velocity.x;
            // Reset the player's jump count.
            _playerMovement.ResetJumps();
        }