Lock and Unlock Camera to HMD during game

Hi there,

I need help on being able to lock and unlock the camera to the HMD during the game.

Any help would be awesome!