Custom first person controller doesn't move in the correct directions

I need to make a custom first person controller for the game i’m making and the controller doesn’t move
with the rotation, so when I hold W in some positions it moves left or right.`

void Start () {

}

void Update () {
	x += sens * Input.GetAxis ("Mouse X");
	y -= sens * Input.GetAxis ("Mouse Y");
	transform.eulerAngles  = new Vector3 (y, x, 0);
		
	moveto = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
	moveto = transform.TransformDirection (moveto);
	moveto *= movespeed;

	cc.Move (moveto * Time.deltaTime);
 }`

You probably just need to multiply the moveto vector by the transforms forward vector; I’m not sure what you’re trying to achieve with transform.TransformDirection, but what I think you want is:

moveto = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
moveto *= transform.forward;
moveto *= movespeed;

Also, if your character has a rigidbody, you will want to use the rigidbody MovePosition and MoveRotation method to move the character so that physics behave correctly. Unity - Scripting API: Rigidbody.MovePosition