Help with camera lock

Is it possible to create “auto aim”? Im making my combat system and i want the camera to lock onto the nearest npc. I’ve tried to look up tutorials but had no luck.