[英]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.