The "Object reference not set to an instance of an object" error is still showing.
I tried Debug.Log on every variable, no errors.
This is my code:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class PlatformSpawn : MonoBehaviour {
public GameObject platform;
public GameObject life;
private Vector3 platformrotation;
private Vector2 platformpoint, lifepoint;
private float platformrange, liferange;
public List<Vector2> SpawnList = new List<Vector2> ();
void Update () {
float randposition = Random.Range (-10f, 10f); //x-axis
platformrange -= 5; //y-axis
float randrotation = Random.Range(-20f, 20f); //z-axis rotation
liferange = platformrange + 1.56f;
platformpoint = new Vector2 (randposition, platformrange);
platformrotation = new Vector3 (0f, 0f, randrotation);
lifepoint = new Vector2 (randposition, liferange);
SpawnList.Add (platformpoint);
GameObject Tlife = (GameObject)Instantiate (life, life.transform.position, life.transform.rotation);
GameObject Tplatform = (GameObject)Instantiate (platform, platform.transform.position, platform.transform.rotation);
Tlife.transform.position = lifepoint;
Tplatform.transform.position = platformpoint;
if (SpawnList.Count >= 10) {
Tplatform.transform.rotation = Quaternion.Euler (platformrotation);
}
}
}
The error is in
GameObject Tlife = (GameObject)Instantiate (life, life.transform.position, life.transform.rotation);
Thanks 4 the help ^_^
P.S. The prefabs are still instantiating without any problems...