我正在關注這個視頻:https : //youtu.be/4HpC--2iowE?t=686
在制作第三人稱動作腳本后,我得到了一個他沒有得到的錯誤。誰能幫我?可能有一個我看不到的非常小的錯誤,我一定是瞎了。我遵循了確切的步驟。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ThirdPersonMovement : MonoBehaviour
{
public CharacterController controller;
public float speed = 6f;
// Update is called once per frame
void Update()
{
float horizontal = Input.GetAxisRaw("Horizontal");
float vetrical = Input.GetAxisRaw("Vertical");
Vector3 direction = new Vector3(horizontal, 0f, vertical).normalized;
if (direction.magnitude >= 0.1f)
{
controller.Move(direction * speed * Time.deltaTime);
}
}
}
錯誤:
Assets\Scripts\ThirdPersonMovement.cs(16,57): 錯誤 CS0103: 當前背景關系中不存在名稱“垂直”
說錯誤在第 16 行。“vector3 direction”所在的位置
如果代碼有點奇怪,對不起,第一次使用這個,對我來說是一個奇怪的設定。提前謝謝你。
uj5u.com熱心網友回復:
有一個錯字:
vetrical
vertical
t 和 r 交換
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/313899.html
上一篇:我不能終生禁用VSCode的斜體
