It says this and whatever I do I cannot fix it.
NullReferenceException: Object reference not set to an instance of an object
PlatformDestroyer.Update () (at Assets/Scripts/PlatformDestroyer.cs:16)
using UnityEngine;
using System.Collections;
public class PlatformDestroyer : MonoBehaviour {
public GameObject platformDestructionPoint;
// Use this for initialization
void Start () {
platformDestructionPoint = GameObject.Find ("PlatformDestructionPoint");
}
// Update is called once per frame
void Update () {
if(transform.position.x < platformDestructionPoint.transform.position.x)
{
Destroy (gameObject);
}
}
}
This is my Platform Generator script
using UnityEngine;
using System.Collections;
public class PlatformGenerator : MonoBehaviour {
public GameObject thePlatform;
public Transform generationPoint;
public float distanceBetween;
private float platformWidth;
// Use this for initialization
void Start () {
platformWidth = thePlatform.GetComponent().size.x;
}
// Update is called once per frame
void Update () {
if (transform.position.x < generationPoint.position.x)
{
transform.position = new Vector3 (transform.position.x + platformWidth + distanceBetween, transform.position.y, transform.position.z);
Instantiate (thePlatform, transform.position, transform.rotation);
}
}
}
what is wrong I cant fix it.
.
↧