【发布时间】:2021-11-23 05:55:32
【问题描述】:
我正在尝试复制编辑器的相机以供运行时使用,并且一切都按预期工作,但我正在尝试缓和运动并且无法使其正常工作。这是我的运动代码。它工作正常,但没有像我想要的那样缓和。
Vector3 move = Vector3.zero;
if (Input.GetKey(KeyCode.W))
move += Vector3.forward * currentSpeed;
if (Input.GetKey(KeyCode.S))
move -= Vector3.forward * currentSpeed;
if (Input.GetKey(KeyCode.D))
move += Vector3.right * currentSpeed;
if (Input.GetKey(KeyCode.A))
move -= Vector3.right * currentSpeed;
if (Input.GetKey(KeyCode.E))
move += Vector3.up * currentSpeed;
if (Input.GetKey(KeyCode.Q))
move -= Vector3.up * currentSpeed;
transform.Translate(move);
我尝试了一个目标 Vector3,将其设置为 move,然后将位置设置为 destination。这确实像预期的那样轻松,但是方向都被打破了。左移前移,右移后移,依此类推。
我已尝试迁移到 fixedUpdate,但仍然没有成功。
任何帮助将不胜感激!
【问题讨论】:
标签: unity3d input camera controls