Exemple #1
0
    public void Respawn()
    {
        AudioManager.PlaySound(AudioManager.Sound.Confirm);
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible   = false;
        PlayerRespawned?.Invoke();
        impact        = Vector3.zero;
        isDead        = false;
        canMove       = true;
        canRun        = true;
        currentHealth = maxHealth;
        PlayerDamaged?.Invoke(currentHealth, maxHealth);
        stamina = maxStamina;
        StaminaChanged?.Invoke(stamina, maxStamina);
        var respawnPosition = new Vector3(152.2615f, 1, 142.5762f);

        // turn off characterController so that it does not override transform.position
        characterController.enabled   = false;
        gameObject.transform.position = respawnPosition;
        characterController.enabled   = true;

        onFireTimer    = 5;
        bleedingTimer  = 10;
        exhaustedTimer = 5;

        animator.SetBool("isDying", false);
        animator.SetBool("isRunning", false);
        animator.SetBool("isAttacking", false);
        animator.SetBool("isIdle", true);
    }
Exemple #2
0
    public void Respawn()
    {
        PlayerIsRespawning = true;
        if (currentCheckpoint == null)
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
        }
        else
        {
            rb2d.velocity      = Vector2.zero;
            transform.position = currentCheckpoint.transform.position;
        }

        isDead = false;
        playerAnimator.SetBool("isDead", isDead);
        respawnUIImage.enabled = false;
        canMove = true;
        if (PlayerRespawned != null)
        {
            PlayerRespawned.Invoke();
        }
    }
 protected virtual void OnPlayerRespawned() => PlayerRespawned?.Invoke(this, EventArgs.Empty);