Hi guys.
I am trying to make a game object, in this case a battery, spawn around the room.
i have created a cylinder with a battery texture and put it in the scene.
using UnityEngine;
using System.Collections;
public class Battery_Script : MonoBehaviour {
public Transform[] spawns;
void Start () {
InvokeRepeating("Spawn", 5 , 5);
}
void Spawn() {
int i = Random.Range (0,spawns.Length);
transform.position = spawns*.position;*
transform.rotation = spawns*.rotation;*
}
}
i have attached this script to it and i keep getting the error message
"MissingReferenceException: The object of type ‘Battery_Script’ has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEditor.GenericInspector.GetOptimizedGUIBlock (Boolean isDirty, Boolean isVisible, UnityEditor.OptimizedGUIBlock& block, System.Single& height) (at C:/buildslave/unity/build/Editor/Mono/Inspector/GenericInspector.cs:19)
UnityEditor.InspectorWindow.FlushOptimizedGUIBlock (UnityEditor.Editor editor) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1430)"
i think its only being called once because collapse isn’t checked on the console so i assume its happening on start.
i don’t destroy it at any point so i’m stumped.
i’m sure i’m missing something obvious
so thanks in advance.