Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Tappy Bird

Discussion in 'Editor & General Support' started by Shigidy, Sep 18, 2014.

  1. Shigidy

    Shigidy

    Joined:
    Dec 14, 2011
    Posts:
    441
    Hi,

    I'm simply using the assets from this pack. https://www.assetstore.unity3d.com/en/#!/content/18684
    I'm trying to make a flappy bird game. After messing with the bird settings I got that pretty close to what I want, however I need some help.

    I'm trying to get the pipes a little closer to what I want. I know what column pool size does, amount of columns on screen at once. I know what spawn rate is, lower the number the closer they are together. I really would like it to be at one, but the second column always is way too close.

    upload_2014-9-18_2-15-34.png

    Anyway, to fix just the first column, because the others are about the spacing I want.

    Finally I want to change all the assets to this. https://www.assetstore.unity3d.com/en/#!/content/21454

    I really don't know how to change the bird, the columns, the background or anything really. Can somebody please help with some or perhaps all of this?

    I've tried changing the bird, but it just goes back to the original one. Also, the original one is like 2 times bigger than the one I want to use. I know that will mess up the collider thing. Would I just have to resize the new sprite in Photoshop or something.

    I didn't really know about the columns or how to change those. Also was wondering about how to add the menu screen like hit play and stuff like that. I know you have to make collider buttons, but I don't know the details with it.

    Finally, could I even upload this to google play using these assets?

    I know this is a lot to ask, but I do appreciate the time.

    Edit: just fixed the columns look, not the code in the picture. I'm starting to get the hang of the sprites and everything. But I really still need to figure out that code, with the second pipe.
     
    Last edited: Sep 18, 2014
  2. Shigidy

    Shigidy

    Joined:
    Dec 14, 2011
    Posts:
    441
    This is about as far as I've gotten so far.
    upload_2014-9-18_3-53-49.png
    -New Ground/Foreground
    -New Sky
    -New Columns

    Still need help with first pipe issue.
    Also need help with audio.
    upload_2014-9-18_4-39-17.png

    The code I borrowed is called "play audio"

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class PlaySound : MonoBehaviour {
    5.     public AudioClip BirdWings;
    6.     public AudioClip BirdDied;
    7.     public AudioClip BirdHit;
    8.     public AudioClip BirdPoint;
    9.     public AudioClip BirdSwoosh;
    10.     // Use this for initialization
    11.     void Start () {
    12.  
    13.     }
    14.     public void PlayMySound(AudioClip i)
    15.     {
    16.         audio.PlayOneShot(i);
    17.     }
    18.     // Update is called once per frame
    19.     void Update () {
    20.  
    21.     }
    22. }
    23.  
    I'm going to try and change the bird soon as well too.
     

    Attached Files:

    Last edited: Sep 18, 2014
  3. Shigidy

    Shigidy

    Joined:
    Dec 14, 2011
    Posts:
    441
    I still need help with this pipe issue. Here is the code I got so far.
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class ColumnSpawnScript : MonoBehaviour
    5. {
    6.     public GameObject columnPrefab;        //the column game object
    7.     public int columnPoolSize = 5;        //how many columns to keep on standby
    8.     public float spawnRate = 3f;        //how quickly columns spawn
    9.     public float columnMin = -1f;        //minimum y value of the column position
    10.     public float columnMax = 3.5f;        //maximum y value of the column position
    11.  
    12.     GameObject[] columns;                //collection of pooled columns
    13.     int currentColumn = 0;                //index of the current column in the collection
    14.  
    15.  
    16.     void Start()
    17.     {
    18.         //initialize the columns collection
    19.         columns = new GameObject[columnPoolSize];
    20.         //loop through the collection and create the individual columns
    21.         for(int i = 0; i < columnPoolSize; i++)
    22.         {
    23.             //note that columns will have the exact position and rotation of the prefab asset.
    24.             //this is because we did not specify the position and rotation in the
    25.             //Instantiate() method call
    26.             columns[i] = (GameObject)Instantiate(columnPrefab);
    27.         }
    28.         //starts our function in charge of spawning the columns in the playable area
    29.         StartCoroutine ("SpawnLoop");
    30.     }
    31.  
    32.     public void StopSpawn()
    33.     {
    34.         //stops our spawning function
    35.         StopCoroutine("SpawnLoop");
    36.     }
    37.  
    38.     //this is a coroutine which manages when columns are spawned
    39.     IEnumerator SpawnLoop()
    40.     {
    41.         //infinite loop: use with caution
    42.         while (true)
    43.         {  
    44.             //To spawn a column, get the current spawner position...
    45.             Vector3 pos = transform.position;
    46.             //...set a random y position...
    47.             pos.y = Random.Range(columnMin, columnMax);
    48.             //...then set the current column to that position.
    49.             columns[currentColumn].transform.position = pos;
    50.  
    51.             //increase the value of currentColumn. If the new size is too big, set it back to zero
    52.             if(++currentColumn >= columnPoolSize)
    53.                 currentColumn = 0;
    54.             //leave this coroutine until the proper amount of time has passed
    55.             yield return new WaitForSeconds(spawnRate);
    56.         }
    57.     }
    58. }
    59.