# Player movement in relation to camera movement

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MainCamera : MonoBehaviour {

``````public GameObject player;
public Transform PlayerTransform;
public Transform cam;

private Vector3 _cameraOffset;
private Vector3 offset;

[Range(0.01f, 1.0f)]
public float SmoothFactor = 0.5f;

public bool RotateAroundPlayer = true;
public float RotationSpeed = 5.0f;
public bool LookAtPlayer = false;

void Start () {
offset = transform.position - player.transform.position;
_cameraOffset = transform.position - PlayerTransform.position;
}

void LateUpdate () {
transform.position = player.transform.position + offset;
if (RotateAroundPlayer)
{
Quaternion camTurnAngle =
Quaternion.AngleAxis (Input.GetAxis ("Mouse X") * RotationSpeed, Vector3.up);
_cameraOffset = camTurnAngle * _cameraOffset;
}
Vector3 newPos = PlayerTransform.position + _cameraOffset;

transform.position = Vector3.Slerp (transform.position, newPos, SmoothFactor);

if (LookAtPlayer || RotateAroundPlayer)
transform.LookAt (PlayerTransform);

transform.position += new Vector3 (Input.x, 0, Input.y) * Time.deltaTime * 5;

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’m trying to get my character to move in the direction the camera is facing, I’ve sorted all the code aside from the direction. I’m getting the “‘UnityEngine.Input’ does not have a definition for x and y” However i know for a fact that I have referenced the axis multiple times. Any idea what’s up? Might just be me being an idiot

transform.position += new Vector3 (Input.x, 0, Input.y) * Time.deltaTime * 5; (This is where I am getting the error)

There’s no `x` or `y` on the `Input` class. There is, however, `Input.GetAxis("Horizontal")` and `Input.GetAxis("Vertical")`.

Input

Input.GetAxis