This is related to my previous question which I solved another way, but now I started on a new script and trying out a suggestion in my previous question, so now I'm stuck again...
my error
'NullReferenceException: Object reference not set to an instance of an object spawnPickup+SpawnAnother$1+$.MoveNext () (at Assets\scripts\spawnPickup.js:13)'
PickUpManager - empty game object spawnPickup.js
var myPickup : GameObject;
function SpawnAnother(currentTransform: Transform){
yield WaitForSeconds (1);
Instantiate(myPickup, currentTransform.position, currentTransform.rotation);
}
pickup > cube
pickup is an empty game object with a rotate JS on it, and cube is the child, which has a collider , is trigger set
var collectSFX : AudioClip;
static var originTransform : Transform;
function OnTriggerEnter (otherCollider : Collider) {
if(otherCollider.gameObject.tag == "player"){
audio.PlayClipAtPoint(collectSFX, gameObject.transform.position);
var score = gameObject.Find("scoreDisplayer").GetComponent(displayScore).AddScore();
var puManager = gameObject.Find("PickUpManager").GetComponent(spawnPickup);
puManager.SpawnAnother(originTransform);
Destroy(gameObject);
}
}
/*
static function StoreOrigin(otherTransform : Transform){
originTransform = otherTransform;
Debug.Log(originTransform.transform.position.z);
}
*/
function start(){
originTransform = gameObject.transform;
Debug.Log(originTransform.transform.position.z);
}
So basically I'm trying to store off the original location of the pickup. When it's destroyed I want to instantiate another one at it's orginal location.
I can then go into the level and drop these all over the place.