Apply camera position and rotation to an object(as an fps hand or gun etc)

Hi,i’m having an hard time to apply my camera rotation to a simple object,i really don’t understand what’s going wrong this is my code for now :

MAT4 model_mat;

  mat4_init(model_mat); 

  MAT4 cam_inverse;

  mat4_inverse(cam_inverse,core_ptr->data->ubo_cam->cam_view);

  VEC3 world_cam_pos;

  world_cam_pos[0] = cam_inverse[3][0];

  world_cam_pos[1] = cam_inverse[3][1];

  world_cam_pos[2] = cam_inverse[3][2];

  mat4_translate(model_mat,world_cam_pos);

  mat4_copy(core_ptr->data->ubo_model[ROBOT0_UBO_MODEL_INDEX].model_mat,model_mat);

with this i can put an object in front of the camera view,but it gets no rotation…so i tried :

mat4_rotate_x(core_ptr->data->ubo_model[ROBOT0_UBO_MODEL_INDEX].model_mat,-((FLOAT)deg_to_rad(core_ptr->mouse->pitch)));
mat4_rotate_y(core_ptr->data->ubo_model[ROBOT0_UBO_MODEL_INDEX].model_mat,-((FLOAT)deg_to_rad(core_ptr->mouse->yaw))); 

and i tried disperatly different combinations,but the maximum that i got was the model rotating in the opposite axis and opposite angle of my view (like i was rotatin and moving up the model would go left) if i go right the model goes down etc…please i need help i have to clue on what’s happening this is becoming a nightmare for me