Hi guys I’m trying to instantiate an object with a parent to a point of view but i get null reference. Here is the code:
var showMessage : boolean;
var someMessage : String;
var prefab : Transform;
var pov : GameObject;
private var video : GameObject;
function OnGUI(){
if(showMessage){
GUI.Box(Rect(Screen.width/2,Screen.height/2, 100, 25),someMessage);
}
}
function OnTriggerEnter(){
showMessage = true;
videostart();
}
function OnTriggerExit(){
showMessage = false;
}
function videostart() {
video = Instantiate(prefab, pov.position, pov.rotation) as GameObject;
video.transform.parent = pov.transform;
}