How can I move a controller in relation to the camera's axis?

I have a simple script to move my character, as seen below;

    float x = Input.GetAxis("Horizontal");
	float y = Input.GetAxis("Vertical");

	Vector3 inputVector = new Vector3(x ,0 ,y); 
	inputVector *= moveSpeed;

	controller.SimpleMove(inputVector); 

It works just fine for moving the character specifically along the x and z axis. my problem is that I would like to have the character move according to the rotation of the camera, rather than the orientation of the world. for example, at the moment, using simplemove with the “a” key held down would give me a vector of (1,0,0) to move on, however, that moves me straight toward the x axis, where I need it to move me toward the camera’s x axis.

You could try multiplying x by camera.transform.right and y by camera.transform.forward, which should give you the relative axis of the camera.
Depending on whether you want the z or y axis for the y movement, you may want to use transform.forward instead.

ie:

float x = Input.GetAxis("Horizontal");
x *= camera.main.transform.right;

float y = Input.GetAxis("Vertical");
y *= camera.main.transform.up;

Vector3 inputVector = new Vector3(x ,0 ,y);
inputVector *= moveSpeed;
 
controller.SimpleMove(inputVector);

I have found a semi functional solution to this problem. using the method TransformDirection I was able to translate the orientation of the camera to world space. Unfortunately, the character orientates himself strangely while moving. anyways, here it is

float x = Input.GetAxis("Horizontal");
float y = Input.GetAxis("Vertical");
Vector3 inputVector = mainCamera.transform.TransformDirection(x, 0, z);
inputVector *= moveSpeed;
controller.SimpleMove(inputVector); 

This part will help you orient your character, though you’ll get the same problem as me

if (inputVector != Vector3.zero){
            transform.rotation = Quaternion.Slerp(transform.rotation,  Quaternion.LookRotation(inputVector),  Time.deltaTime * 20); // What this means is that it is rotating FROM the first parameter to the second at the pace of the third parameter		
}