I need to instantiate a target and player then get the camera mouse control script and set its target to the player. In the code below, the Get Component script returns null. Is there a way to get a component from an instantiated prefab? Any help is appreciated.
SceneObjectData.CurrentSceneObjects.MainCamera = Instantiate(SceneObjectData.SceneObjectPrefab.MainCamera_Prefab) as GameObject;
SceneObjectData.CurrentSceneObjects.adventurer = Instantiate(SceneObjectData.SceneObjectPrefab.Adventurer_Prefab) as GameObject;
//Target the Adventurer with the point camera script
CameraMouseControl CameraMouseControlScript;
CameraMouseControlScript = SceneObjectData.CurrentSceneObjects.MainCamera.GetComponent(“CameraMouseControl”) as CameraMouseControl;
CameraMouseControlScript.target = SceneObjectData.CurrentSceneObjects.adventurer;