在Unity中未设置输入轴垂直(C#)

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

我正在尝试实现一个玩家移动脚本,但是每当我运行该项目时,它只会显示错误“ ArgumentException:未设置输入轴顶点。要更改输入设置,请使用:编辑->设置->输入PlayerMovement.Update ()(位于Assets / PlayerMovement.cs:14)“

我尝试进入输入控件并'设置垂直轴',但说实话,我不知道如何。另外,我不确定是否应该是这样,但是当我将输入设置中的垂直轴更改为y轴时,它也会自动将水平轴更改为y。这是我的代码,以防万一,但没有显示任何错误

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    public CharacterController controller;

    public float speed = 12f;
    // Update is called once per frame
    void Update()
    {
        float x = Input.GetAxis("Horizontal");
        float z = Input.GetAxis("Verticle");

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

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

另外,我在Unity中使用C#。

谢谢!B.G

c# visual-studio unity3d input axis
1个回答
0
投票
float z = Input.GetAxis("Verticle");
© www.soinside.com 2019 - 2024. All rights reserved.