player look in camera direction

Hello I am working on my character and camera movement but I am having trouble. When I press the button w I want my player to face the same direction as my camera but only on the Y axis can someone please help.

Hi I have been looking to do the same sort of function!

I have had no luck in putting the above code into my current move script.

This is what I have at the moment

private Vector3 moveDirection = Vector3.zero;
public Vector3 MoveVector { get; set; }

public void UpdateMotor() 
{
	SnapAlignCharacterWithCamera();
}

void Update() 
{
    CharacterController controller = GetComponent<CharacterController>();
	
    if (controller.isGrounded) 
	{
        moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
        moveDirection = transform.TransformDirection(moveDirection);
        moveDirection *= speed;
		
        if (Input.GetButton("Jump"))
            moveDirection.y = jumpSpeed;	         
    }
	
    moveDirection.y -= gravity * Time.deltaTime;
    controller.Move(moveDirection * Time.deltaTime);
}

}

Was wondering if I could get some help :smiley: I’m a massive scripting noob :confused:

Thanks