Your camera switching mechanism seems fine, that error message indicates that there’s a problem with your casting. Can you show:
- How did you declare that object type variable for the NPC camera
- Where did you place the camera for the NPC
- The camera’s placement under the hierarchy and it’s dependencies