Commit 19d1b513 authored by Bene's avatar Bene

Changed Spawnerscripting to prevent nullreferences on objects after quitting the game.

parent 306d60df
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
public class PlattformGenerating : MonoBehaviour
{
public GameObject spawner;
private SpawnerScript spawner;
private void OnBecameInvisible()
{
spawner.GetComponent<SpawnerScript>().generateplattform();
//Destroy(gameObject);
if (spawner != null) spawner.generateplattform();
}
private void Start()
{
spawner = GameObject.FindWithTag("Scribblespawner");
spawner = FindObjectOfType<SpawnerScript>();
}
}
using System.Collections;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Random = UnityEngine.Random;
public class SpawnerScript : MonoBehaviour
{
......@@ -19,7 +21,10 @@ public class SpawnerScript : MonoBehaviour
public void generateplattform()
{
amountofplattforms--;
}
private void Update()
{
for(int i = 0; amountofplattforms < maximumamountofplattforms; i++)
{
int rand = Random.Range(1, 13);
......@@ -71,8 +76,6 @@ public class SpawnerScript : MonoBehaviour
}
}
public void generator(GameObject scribbleobject, int rand)
{
int plattformoffset = Random.Range(-6, 6);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment