- Home /
Problem with AddComponet(SCRIPT) on a Instantiated PREFAB
okay, i really need some help here.
I have a PREFAB of a [ship]. this PREFAB has a few GameObjects as children, one of them is a lineRenderer attached to the [engine] gameObject.
I INSTANTIATE the PREFAB, no problem
I then addComponent(SCRIPT_ship) to the newly instantiated prefab. , no problem here either
When i run the game, the SCRIPT_ship.js doesn't know what lineRenderer is being referenced in the PREFAB, and returns the error : NullReferenceException: Object reference not set to an instance of an object.
If i attach the SCRIPT_ship.js to the PREFAB manually in the editor, i can link up the vars in the SCRIPT_ship.js no problem. how do i link these up with script instead.
please help :) thanx in advance for any assistance you can provide, i have been struggling with this for hours.