Cannot move while turning in code

I cannot move my character when i rotate it using the mouse when it rotates the character freezes, and i cannot move forward nor backwards. NEED HELP been trying to figure this out all day.

void Update()
{
float rX = Input.GetAxis(“Mouse X”) * smooth;
rY += Input.GetAxis(“Mouse Y”) * smooth;
rY = Mathf.Clamp(rY, -45, 45);
transform.Rotate(0, rX, 0, Space.World);
if (cam != null){
Vector3 rot = new Vector3(-rY, cam.transform.eulerAngles.y, cam.transform.eulerAngles.z);
cam.transform.eulerAngles = rot;
}
}
void FixedUpdate () {
if (Input.GetKey(KeyCode.W))
{
rb.MovePosition(transform.position + transform.forward * movespeed);
anim.SetBool(“walking”, true);
}
if (Input.GetKey(KeyCode.S))
{
rb.MovePosition(transform.position + transform.forward * -movespeed);
anim.SetBool(“walking”, true);
}
}

I tested it on a cube and it rotates and moves at the same time. I didn’t have an animator on it, so I commented out those lines. There really isn’t a reason for it to interfere that I can see.

Hi there. Have you been able to work this out, yet?

Please look over this page for how to post code nicely on the forums for future posts :slight_smile: