- Home /
It doesn't add points
Hello, I am doing the Flappy Bird script and I'm actually finished but I have one problem which is that when I'm going through the first column, I get a point but when I go through any other columns it doesn't add points so the points will stay on 1.
ColumnPool script:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class ColumnPool : MonoBehaviour { public int columnPoolSize = 5; public GameObject columnPrefab; public float spawnRate = 4f; public float columnMin = -1f; public float columnMax = 3.5f;
private GameObject[] column;
private Vector2 objectPoolPosition = new Vector2 (-15, -25f);
private float timeSinceLastSpawned;
private float spawnXPosition = 10f;
private int currentColumn = 0;
// Use this for initialization
void Start ()
{
column = new GameObject[columnPoolSize];
for (int i = 0; i < columnPoolSize; i++)
{
column[i] = (GameObject)Instantiate (columnPrefab, objectPoolPosition, Quaternion.identity);
}
}
// Update is called once per frame
void Update ()
{
timeSinceLastSpawned += Time.deltaTime;
if (GameController.instance.gameOver == false && timeSinceLastSpawned >= spawnRate)
{
timeSinceLastSpawned = 0;
float spawnYPosition = Random.Range (columnMin, columnMax);
column [currentColumn].transform.position = new Vector2 (spawnXPosition, spawnYPosition);
currentColumn++;
if (currentColumn >= columnPoolSize)
{
currentColumn = 0;
}
}
}
}
Column script:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Column : MonoBehaviour { private void OnTriggerEnter2D (Collider2D other) { if (other.GetComponent () != null) { GameController.instance.BirdScored (); } } }
I don't see anything adding points, I don't even see points defined..
Your answer
Follow this Question
Related Questions
How do I create an effective spawn point script for multiple scenes and change music each scene? 1 Answer
Points when an enemy dies. 2 Answers
Move object around another custom-made object 1 Answer
Find two points which are on 120 degrees from a third point. 3 Answers
domination capture points 1 Answer