I am making a game which is really similar to flappy bird for my school project. I successfully made the pipes regenerate but when I trying to destroy pipes that error appears and my pipes just suddenly stop generate.
This is my script for generating pipes
using UnityEngine;
using System.Collections;
public class Pipes : MonoBehaviour {
public GameObject thepipes;
public float maxHeight;
public float minHeight;
public float DistanceBetween;
public Transform generatorThreshold;
// Use this for initialization
void Start () {
transform.position = new Vector3 (transform.position.x + DistanceBetween, transform.position.y, transform.position.z);
}
// Update is called once per frame
void Update () {
if (transform.position.x < generatorThreshold.position.x)
{
Instantiate (thepipes, new Vector3 (transform.position.x, Random.Range (minHeight, maxHeight), transform.position.z), transform.rotation);
transform.position = new Vector3 (transform.position.x + DistanceBetween, transform.position.y, transform.position.z);
}
}
}
And this is my script for destroying pipes
using UnityEngine;
using System.Collections;
public class Destroy : MonoBehaviour {
public Transform destructionPoint;
// Use this for initialization
void Start () {
destructionPoint = GameObject.Find ("Destruction Point").transform;
}
// Update is called once per frame
void Update () {
if (transform.position.x < destructionPoint .position.x)
{
Destroy (gameObject);
}
}
}
And this error keeps occur when I press play.
I really need help for my school project immediately…!! Thank you!!
If I made any mistake, please point it out so I can fix it…
Oh, I am refering a tutorial by gameplusjames in Youtube. This is the URL