I want to instantiate a game object and parent it to the main camera of my first person controller. The script to instantiate the game object is on the first person controller. The main camera is a child of the first person controller. The instantiated game object will be the child of the child (main camera) of the first person controller.
Here is my script, which is a returning a “null reference” error:
var playersBow : GameObject;
var mainCamPos : Vector3;
var mainCamPos = transform.Find("Main Camera").GetComponent(Transform).transform.position;
var newBow : GameObject = Instantiate(playersBow, mainCamPos, Quaternion.identity);
newBow.transform.parent.position = mainCamPos;
newBow.transform.localRotation = Quaternion.identity;
Thanks for the help. I’ve been banging my head against the wall on this one.