How to make the character move only left and right when it enters trigger box

are you using the Project Setting or Enhanced Input Subsystem for your input

either the trigger will tell the Actor that the change shall take place, or the Character will signify it is in the trigger. the Actor being told of the change is cleaner, and will lead to more re-usability, modularity, and less casting (for lower memory footprint)

the simplest answer for either method before optimization is to have a boolean check in the forward-back and maybe Look for when the bool is in state then it disallows reading those inputs.

for the Enhanced Input Subsystem: you can create an Input Mapping Context that just doesn’t include the Forward-Back and Look inputs. Just be sure to change it back when they leave

either implementation can be accomplished by communicating the change with the OnOverlapBegin() and OnOverlapEnd()

the next step is to constrain the Camera, this will vary/depend on the implementation you are using for the Camera. where like the third Person Camera will need to set CameraBoom->bUsePawnControlRotation = false (again remembering to reactivate this on returning everything)

I would strongly suggest that you attempt to smooth transition/interpolate the camera if it needs to be moved in terms of angle to accomplish your effect