我new input system在我的統一專案中使用。我也用Cinemachine. 我Cinemachine Input Provider用來將輸入從舊系統更改為新系統。當我更改max speed為Input Value Gain虛擬相機設定的速度欄位時(我這樣做是因為它是控制相機最舒適的方式)我遇到了一個問題。我的問題:當我的角色在一段時間后移動時,相機速度會發生變化。如果我開始向相反方向移動,相機速度就會恢復正常。這與場景中的其他組件無關。我的場景只有平面、立方體、相機和我的角色。
這是我的角色控制代碼(忽略移動方向的可怕計算):
private Rigidbody _rb;
private Vector2 _moveDirection;
private float speed = 5f;
private void Awake()
{
_rb = GetComponent<Rigidbody>();
Cursor.lockState = CursorLockMode.Locked;
}
public void OnMove(InputAction.CallbackContext context)
{
_moveDirection = context.ReadValue<Vector2>();
}
private void FixedUpdate()
{
Move(_moveDirection);
}
private void Move(Vector3 moveDirection)
{
float scaledMoveSpeed = speed * Time.deltaTime;
moveDirection = new Vector3(Camera.main.transform.forward.x, 0, Camera.main.transform.forward.z).normalized * moveDirection.y new Vector3(Camera.main.transform.right.x, 0, Camera.main.transform.right.z).normalized * moveDirection.x;
_rb.MovePosition(transform.position moveDirection * scaledMoveSpeed);
}
這是相機設定的螢屏截圖和Cinemachine Input Provider:

以及設定截圖Input Actions:


uj5u.com熱心網友回復:
我為那些將面臨這個問題的人找到了解決方案!在您的main camera, 在CinemachineBrain組件中,將Update Methodfrom更改Smart Update為Late Update。那應該有幫助
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/533278.html
