【发布时间】: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。如果我选择脚本附加到的玩家游戏对象,游戏也会变得无法玩。
你的两分钱是多少?
【问题讨论】:
-
Premature Optimization Is the Root of All Evil 你确定 260 FPS 有问题吗?这似乎是帧速率的急剧下降,但如果它只下降到比大多数人想要的快四到八倍的帧速率,是否真的需要修复?
标签: c# performance unity3d optimization scripting