Итак, я нахожусь в Codemonkeys 'Learn Unity Beginner/Productediate Course, и я нахожусь в «Рефакторе системы ввода», где вам нужно получить ввод игрока через новую систему ввода
Поэтому я попробовал это в своей основной игре, и я попал в эту проблему, где по какой -то причине я проверял каждый шаг, когда я входил в консультации, когда я был в курсе (я был (я был в целом), когда я проверял Zerve (). Vector < /p>
Я теперь сделал новый свежий проект только с: символом игрока (пустой объект и его ребенок - капсула), игрок и файл Gameinput. GameInput назначается поле в объекте Player. Нет сообщения об ошибке < /p>
player < /p>
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
[SerializeField]
private int speed = 5;
[SerializeField]
private GameInput gameInput;
private void Update()
{
Vector2 inputVector = gameInput.GetMovementVector();
inputVector = inputVector.normalized;
Vector3 moveDir = new Vector3(inputVector.x, 0, inputVector.y);
transform.position += moveDir *Time.deltaTime*speed;
}
}
< /code>
GameInput < /p>
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameInput : MonoBehaviour
{
private PlayerInputActions playerInputActions;
private void Awake()
{
playerInputActions = new PlayerInputActions();
playerInputActions.Player.Enable();
}
public Vector2 GetMovementVector()
{
Vector2 inputVector = playerInputActions.Player.Move.ReadValue();
return inputVector;
}
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... s-zero-eve