How to orientate a character's movement with its rotation?

void Start()
{
player.GetComponent();
Cursor.lockState = CursorLockMode.Locked;
}

void Update()
{
    //camera Rotation
    float CamHori = Input.GetAxis("Mouse X");
    transform.Rotate(Vector3.up * sensitivity * CamHori);

}


void FixedUpdate()
{
    //movement
    float horizontal = Input.GetAxisRaw("Horizontal");
    float vertical   = Input.GetAxisRaw("Vertical");

      

    Vector3 movement = player.velocity;
    movement.x = horizontal * speed;
    movement.z = vertical * speed;
    player.velocity = movement;

}

}

Hello.

There are 2 Rotations, 2 positions and 2 scales.

transform.position and transform.localPosition

One is relative to world coordinates, the otherone is relative to its parent.

Te same way, you can determinate a rotation by ots own relative rotation

transform.formward is a vecotr that is always poiting “forward” in its own rotation.

Also know that rotations can be done by quaternions (transfomr.rotation) and Vector3 (transform.EulerAngles)

Bye