Unity 中未设置垂直输入轴 (C#)
input axis vertical is not set up (C#) in Unity
我正在尝试实施玩家移动脚本,但每当我 运行 项目时,它只会显示错误 "ArgumentException: Input Axis Verticle is not setup. To change the input settings use: Edit -> Settings -> Input PlayerMovement.Update () (at Assets/PlayerMovement.cs:14)"
我尝试进入输入控件和 'setting up the verticle axis' 但老实说,我不知道该怎么做。另外,我不确定它是否应该是这样的,但是当我将输入设置中的垂直轴更改为 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
float z = Input.GetAxis("Verticle");
改为
float z = Input.GetAxis("Vertical");
关于将来更改输入的详细说明:https://docs.unity3d.com/Manual/class-InputManager.html
我正在尝试实施玩家移动脚本,但每当我 运行 项目时,它只会显示错误 "ArgumentException: Input Axis Verticle is not setup. To change the input settings use: Edit -> Settings -> Input PlayerMovement.Update () (at Assets/PlayerMovement.cs:14)"
我尝试进入输入控件和 'setting up the verticle axis' 但老实说,我不知道该怎么做。另外,我不确定它是否应该是这样的,但是当我将输入设置中的垂直轴更改为 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
float z = Input.GetAxis("Verticle");
改为
float z = Input.GetAxis("Vertical");
关于将来更改输入的详细说明:https://docs.unity3d.com/Manual/class-InputManager.html