簡體   English   中英

優化用戶輸入的性能

[英]Optimizing the performance for user input

我正在開發一個游戲,主角的劇本有點像這樣:

在更新(每幀循環)方法上,我稱之為函數

void Update(){

   InputManager();  //I set the Vector3 direction vector for the player's movement, and 

   Move();          //I make the player move according to the InputManager() direction vector. 
                    //I also set a boolean for every player state (eg. isMoving, isCrouching, isSliding, isGrounded)

   SpeedManager();  //Performes a Linear Interpolation (Mathf.Lerp) between the current speed and the final speed for every input given. 
                    //This includes the direction vector as well as sprinting and sliding

   AnimationManager();  //We check the booleans and apply an animation accordingly
}

該腳本運行良好,但我對性能感到擔憂,因為當我按下輸入時游戲從 400FPS 下降到 260FPS。 如果我 select 玩家游戲 object 附加到該腳本,則游戲也變得無法玩。

你的兩分錢是多少?

使用 Unity Profiler 查看您的時間都花在了哪里。 這是解決性能問題的最佳方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM