1、键盘控制2d角色移动
void Update()
{
float horizontal = Input.GetAxis("Horizontal");
float vertical = Input.GetAxis("Vertical");
Vector2 position = transform.position;
position.x = position.x + 0.01f * horizontal;
position.y = position.y + 0.01f * vertical;
transform.position = position;
}
2、设置游戏帧率
QualitySettings.vSyncCount = 0;
Application.targetFrameRate = 10;
3、设置物体移动速度跟帧率无关:
position.x = position.x + 0.1f * horizontal * Time.deltaTime;
position.y = position.y + 0.1f * vertical * Time.deltaTime;