"Assets/MovePlayer.cs(27,70): error CS1061: 'Vector3' does not contain a definition for 'Input' and no accessible extension method 'Input' accepting a first argument of type 'Vector3' could be found (are you missing a using directive or an assembly reference?)"
I am making a small game, I've been trying to add camera relative movements and it keeps showing me the error above.
Here is my code for reference:
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;
}
}
I've also added a CameraLook
component to my Main Camera, if you would like to look at that as well.
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;
}
}