【问题标题】:Optimizing the performance for user input优化用户输入的性能
【发布时间】:2020-08-16 23:08:06
【问题描述】:

我正在开发一款游戏,主角的剧本是这样的:

在更新(每帧循环)方法上,我称之为函数

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。如果我选择脚本附加到的玩家游戏对象,游戏也会变得无法玩。

你的两分钱是多少?

【问题讨论】:

标签: c# performance unity3d optimization scripting


【解决方案1】:

使用 Unity Profiler 查看您的时间都花在了哪里。这是解决性能问题的最佳方式。

【讨论】:

  • 谢谢!当然会检查一下,您认为在输入函数本身中包含输入的所有行为会有所帮助吗?
猜你喜欢
  • 2019-12-29
  • 1970-01-01
  • 1970-01-01
  • 2020-11-08
  • 1970-01-01
  • 1970-01-01
  • 2018-03-05
  • 1970-01-01
  • 2013-03-17
相关资源
最近更新 更多