在 Unity 中,播放器正在旋转而不是移动

问题描述 投票:0回答:0

我试图在 Unity 中制作 3d 平台游戏,所以我看了 Brackeys 的一个教程。在编写了使用 WASD 和箭头键移动播放器的部分后,我对其进行了测试。但是当我试图移动时,播放器会原地旋转。这是我使用的代码:

public CharacterController 控制器; 公共浮动速度 = 12f;

void Update() {
    float x = Input.GetAxis("Horizontal");
    float z = Input.GetAxis("Vertical");

    Vector3 move = transform.right * x + transform.forward * z;

    controller.Move(move * speed * Time.deltaTime);
}

我完全不知道为什么会这样。

unity-game-engine 3d
© www.soinside.com 2019 - 2024. All rights reserved.