How do I enable/disable a camera on an instantiated prefab?

What I'm doing is loading my Player Character as a prefab which then has the ability to instantiate a 2nd prefab that is supposed to be able assume control while the player character is locked in place.

The prefab instantiated by the player character and the player character has a camera (nested) attached to them. I'm trying to slect the prefab's camera so that when the player is controlling the prefab te prefab's camera is active as the main camera.

The problem I'm running into is that I can't figure out how to refer to the prefab's camera to activate or deactivate it.

"gameObject.GetComponent" only refers to the components of the prefab and not to the nested camera so I'm lost.

1 Reply

@Durakken I'm not sure if you ever figured out how to solve this issue of yours. I ran into a similar problem with my own project. I was instantiating some vehicles with cameras attached but inactive. I wanted to pick a vehicle out of the various spawned ones to control, but needed to have the desired cameras become active and I found that I could not do this from the spawn script directly. I eventually got it to work by attaching an "EnableCameras" script to the vehicle prefab that looked like this: