"Assets / MovePlayer.cs (27,70): ошибка CS1061:« Vector3 »не содержит определения для« Input », и нет доступного метода расширения« Input », принимающего первый аргумент типа« Vector3 ». (вам не хватает директивы using или ссылки на сборку?) "
Я делаю небольшую игру, я пытаюсь добавить относительные движения камеры, и она продолжает показывать мне ошибку выше.
Вот мой код для справки:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MovePlayer : MonoBehaviour
{
public Transform cam;
Vector2 input;
void Update()
{
input = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
input = Vector2.ClampMagnitude(input,1);
Vector3 camF = cam.forward;
Vector3 camR = cam.right;
camF.y = 0;
camR.y= 0;
camF = camF.normalized;
camR = camR.normalized;
transform.position += (camF*input.y + camR.input.x)*Time.deltaTime*5;
}
}
Я также добавил CameraLook
компонент к моей основной камере, если вы хотите посмотреть на это.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraLook : MonoBehaviour {
Vector2 rotation = new Vector2 (0, 0);
public float speed = 3;
void Update () {
rotation.y += Input.GetAxis ("Mouse X");
rotation.x += -Input.GetAxis ("Mouse Y");
transform.eulerAngles = (Vector2)rotation * speed;
}
}