private IEnumerator ResetPlayer()
        {
            if (playerGameObject == null)
            {
                yield return(new WaitUntil(() => playerGameObject != null));
            }

            PlayerMovement playerMovement = playerGameObject.GetComponent <PlayerMovement>();

            playerMovement.ResetSpeed();
            playerMovement.enabled = false;
            CharacterControllerGravity gravity = playerGameObject.GetComponent <CharacterControllerGravity>();

            gravity.enabled = false;
            Spellcasting spellcasting = playerGameObject.GetComponent <Spellcasting>();

            spellcasting.ResetMana();
            spellcasting.CmdSetCanCastSpells(false);
            Animator animator = playerGameObject.GetComponent <Animator>();

            if (animator != null)
            {
                animator.SetFloat("Speed", 0);
                animator.SetBool("IsJumping", false);
            }
            playerGameObject.transform.position = spawnPosition;
            playerGameObject.transform.rotation = spawnRotation;
            StartCoroutine(EnablePlayerControls());
        }
        private IEnumerator EnablePlayerControls()
        {
            isFrozen = true;
            yield return(new WaitForSeconds(NetworkManager.WaitBeforeControlsEnableInSeconds));

            isFrozen = false;

            CharacterControllerGravity gravity = playerGameObject.GetComponent <CharacterControllerGravity>();

            gravity.enabled = true;

            PauseMenu pauseMenu = FindObjectOfType <PauseMenu>();

            if (pauseMenu != null && pauseMenu.IsOpen)
            {
                yield break;
            }

            PlayerMovement playerMovement = playerGameObject.GetComponent <PlayerMovement>();

            playerMovement.enabled = true;
            Spellcasting spellcasting = playerGameObject.GetComponent <Spellcasting>();

            spellcasting.CmdSetCanCastSpells(true);
        }
示例#3
0
 public override void OnStartAuthority()
 {
     controller        = GetComponent <CharacterController>();
     controllerGravity = GetComponent <CharacterControllerGravity>();
     animator          = GetComponent <Animator>();
 }