【问题标题】:PauseMenu - FPS Camera still moves when in PauseMenuPauseMenu - FPS 相机在 PauseMenu 中仍然移动
【发布时间】:2019-05-10 04:06:10
【问题描述】:

每当我暂停时,一切都会停止,这就是我想要的样子,但唯一不会停止的是相机。我移动光标,相机仍然跟随。我想让它冻结。我正在资产商店中使用 FPS 控制器资产

 using System.Collections;
 using System.Collections.Generic;
 using UnityStandardAssets.Characters.FirstPerson;
 using UnityEngine;
 using UnityEngine.SceneManagement;

 public class PauseMenu : MonoBehaviour
 {
     public static bool GameIsPaused = false;
     static bool IsPaused = false;

     public GameObject pauseMenuUI;

     // Update is called once per frame
     void Update()
     {
         if (Input.GetKeyDown(KeyCode.Escape))
         {
             if (GameIsPaused)
             {
                 Resume();
             } else
             {
                 Pause();
             }
         }
     }

     public void Resume()
     {
         pauseMenuUI.SetActive(false);
         Time.timeScale = 1f;
         AudioListener.pause = false;
         GameIsPaused = false;
     }

     void Pause()
     {
         pauseMenuUI.SetActive(true);
         Time.timeScale = 0f;
         AudioListener.pause = true;
         GameIsPaused = true;
     }

     public void LoadMenu()
     {
         Time.timeScale = 1f;
         SceneManager.LoadScene("Menu");
     }

     public void QuitGame()
     {
         Debug.Log("Exiting Game");
         Application.Quit();
     } 
 }

【问题讨论】:

    标签: c# visual-studio unity3d


    【解决方案1】:

    获取对字符控制器脚本的引用,然后禁用它:

    mycharfpscon.enabled = false;
    

    然后重新启用它:

    mycharfpscon.enabled = true;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-13
      • 1970-01-01
      • 2012-11-30
      • 1970-01-01
      • 1970-01-01
      • 2021-08-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多