1
votes

"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;
    }
}
2

2 Answers

1
votes

This likely needs to be transform.position += (camF*input.y + camR * input.x)*Time.deltaTime*5;

You're trying to access camR.input which isn't a property of camR which is a Vector3. I think you're intending to multiply camF by input.x instead.

FYI, You can double click on the error message in visual studio, or monodevelop and it will take you to the error line.

1
votes

You have camR.input.x, which means it's trying to access a member of camR (which is a Vector3) called input, which doesn't exist.

You meant to write camR * input.x.