How to change Input Axis as rotating the camera?

So I have this 3rd person game I’m working on and i have an orbit script to rotate around the player, now as I’m rotating I want to change the axis of the inputs so if the camera is facing the front of the player then instead of using positive 1 I want to use negative 1 to bring the player forward. But I’m confused on how to do this and which object to attach this script to, player or the camera?

Down is my camera Script

``````public class MouseLook2 : MonoBehaviour {

public Transform target;
public float distance = 20.0f;
public float zoomSpd = 2.0f;

public float xSpeed = 240.0f;
public float ySpeed = 123.0f;

public int yMinLimit = -723;
public int yMaxLimit = 877;

private float x = 0.0f;
private float y = 0.0f;

public void Start () {
Vector3 angles = transform.eulerAngles;
x = angles.y;
y = angles.x;

// Make the rigid body not change rotation
//		if (rigidbody)
//			rigidbody.freezeRotation = true;
}

public void LateUpdate () {
if (target) {
x -= Input.GetAxis("PS4_RightAnalougeHorizontal") * xSpeed * 0.02f;
y += Input.GetAxis("PS4_RightAnalougeVertical") * ySpeed * 0.02f;

y = ClampAngle(y, yMinLimit, yMaxLimit);

//distance -= Input.GetAxis("Fire1") *zoomSpd* 0.02f;
//distance += Input.GetAxis("Fire2") *zoomSpd* 0.02f;

Quaternion rotation = Quaternion.Euler(y, x, 0.0f);
Vector3 position = rotation * new Vector3(0.0f, 0.0f, -distance) + target.position;

transform.rotation = rotation;
transform.position = position;

}
}//End of last update

public static float ClampAngle (float angle, float min, float max) {
//		if (angle < -360.0f)
//			angle += 360.0f;
//		if (angle > 360.0f)
//			angle -= 360.0f;
return Mathf.Clamp (angle, min, max);
}

}
``````

Another one for my Player

``````public class DrakeWalking : MonoBehaviour {

Animator anim;
CharacterController controller;

public float walkSpeed = 7f;
public float gravity = 50f;
public float rotationSpeed = 10f;
private float yRoat = 90;
public Transform body;
public float runSpeed;
private bool running = false;
//________________________________________________________________//

void Start ()
{

anim = GetComponent<Animator> (); //Get the component for the animator
controller = GetComponent<CharacterController> ();

}//End OF start
//____________________________________________________________________//

void Update ()
{

float move = Input.GetAxis ("Vertical"); //to set the float in the animator
//variable called vertical, type vector3 = the transform's direction, move it forward on the z axis
Vector3 vertical = transform.TransformDirection (Vector3.forward);
Vector3 horizontal = transform.TransformDirection (Vector3.right);
Vector3 height = transform.TransformDirection (Vector3.up);

//
//controller.Move((vertical * (walkSpeed * Input.GetAxis("Vertical"))) * Time.deltaTime);
//controller.Move((horizontal * (walkSpeed * Input.GetAxis("Horizontal"))) * Time.deltaTime);

//yRoat += 5 * Input.GetAxis("Mouse X");
yRoat += 1.5f * Input.GetAxis ("Horizontal") * rotationSpeed; //use the horizontal keys to rotate

transform.rotation = Quaternion.Euler (0, yRoat, 0); //rotate the player

controller.Move (height * -gravity * Time.deltaTime);

if (controller.isGrounded) {//If player is grounded then move

anim.SetFloat ("Speed", move);
controller.Move ((vertical * (walkSpeed * Input.GetAxis ("Vertical"))) * Time.deltaTime);
controller.Move ((horizontal * (walkSpeed * Input.GetAxis ("Horizontal"))) * Time.deltaTime);

} else {

anim.SetBool ("Run", false);
anim.SetFloat ("Speed", 0);
}

//If the left analouge stick axis is greater than 0 and the R2 axis is greater than 0 then do the following
if (Input.GetAxis ("Vertical") > 0 && Input.GetButton ("PS4_R2")) {
//
//
//
running = true;
Vector3 R2Axis = transform.TransformDirection (Vector3.forward);

controller.Move ((R2Axis * (runSpeed * Input.GetAxis ("PS4_R2"))) * Time.deltaTime);
anim.SetBool ("Run", true); //run is true

} else {

anim.SetBool ("Run", false); //run is false
anim.SetFloat ("Speed", move); //and walk again
running = false;
}

}
//End of Update
//_____________________________________________________________________________________//

}//End OF Class
``````

Sounds like you want to use InverseTransformDirection to adjust the input relative to the transform of the camera: