Flappy Bird in Unity II: 2/9/24

Braeden Stanton Avatar

·

Currently in the flappy bird game I added a sector in the middle of the pipe to check if the bird passes that area it add one to the score I also widen the gap between the pipes.

The Video That I used:

The photo of the pipes:

The bird passes threw the green area it adds one to the score

The code for the passing area:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class pipeTrigger : MonoBehaviour 
{
	public LogicScript logic;
	// Use this for initialization
	void Start () {
		logic = GameObject.FindGameObjectWithTag("Logic").GetComponent<LogicScript>();
	}
	
	// Update is called once per frame
	void Update () {
		
	}
//
	private void OnTriggerEnter2D(Collider2D collision)
	{
		logic.addScore();
	}
}

The code finds the green area in the middle of the pipe(logic = GameObject.FindGameObjectWithTag(“Logic”).GetComponent<LogicScript>(); is the code that finds the area), then when the bird pass that green area then it adds one point to the (score(private void OnTriggerEnter2D(Collider2D collision) { logic.addScore(); } is the code that adds to the score)

Leave a Reply

Your email address will not be published. Required fields are marked *