NullReferenceException is for zKothQ.Target, I’ve got that much figured out. I just can’t for the life of me figure out why it’s not referencing anything. I would think that it wouldn’t instantiate my object if there’s no reference, but the object is being instantiated, it just seems zKothQ stays empty.
private int Metal;
public GameObject KothQ;
public KothQ zKothQ;
private RaycastHit vHit = new RaycastHit ();
private Ray vRay;
void Update () {
vRay = Camera.main.ScreenPointToRay (Input.mousePosition);
Metal = 10;
if(Input.GetKeyUp("q")){
if(Physics.Raycast (vRay, out vHit, 1000)) {
if(Metal > 0){
Metal = Metal - 1;
zKothQ = Instantiate(KothQ, transform.position, transform.rotation) as KothQ;
zKothQ.Target = vHit.point;
}
else{
}
}
}
}