how to move player forward relative to camera forward with "mouse-y" input

hi!
First of all im new to scripting.
I have done intense searching in the unity answers, the forum and the script reference but i can’t get a solution…
I use mouse-x and mouse-y input to move a 3rdperson player. (the x & y movement of the mouse should be translated to moving the character forward, backwards, left and right) Mouse-x also give a slight rotation so you can steer the player. But rotating doesn’t influence the direction of the x and z axis. So when i rotate 180 degrees and I Make a forward input, the player just moves backwards along the original and unchanged z-axis

heres my script:

function Update () {

transform.position.x -= (Input.GetAxis(“Mouse X”) * 0.04);

transform.position.z += (Input.GetAxis(“Mouse Y”) * 0.04);

transform.rotation.y -= (Input.GetAxis(“Mouse X”) * 0.01);

}

I know it has something to do with transform.direction but from all the examples I stumbled upon, they all work with key input * speed as input, while i have raw numbers from the x and y movement of the mouse. My scripting knowledge is to narrow to make these things compatible.
Can anyone push me in the right direction?
Thanks in advance, any advice will be greatly appreciated!
Laurens.

You can get the Camera’s forwrad direction by using:

Camera.mainCamera.transform.forward

Am I correct in assuming that you want to move the player along the camera’s direction. So you would want to do something like this:

player.transform.position += Camera.mainCamera.transform.forward * mouseYDelta;

player.transform.position += Camera.mainCamera.transform.right * mouseXDelta;

This exact code will not work but it should give you an idea of what to do.