Unity 2D - Flappy Bird - Pipe movement and Score Text

Hi, I’m learning Unity by making a Flappy Bird. I have 2 problems, 1st, the pipes keep dropping down to the ground (please see video); 2nd, I can’t drag and drop ‘Score Text’ to ‘Score Text - Script’ (please see instruction Step 15).

Video: http://tinypic.com/player.php?v=o51e7l>&s=8

Instruction: https://www.mvcodeclub.com/lessons/flappy-bird-in-unity

Full package: http://s000.tinyupload.com/index.php?file_id=07972794715502536291

1893802–121933–Flappy Bird in Unity - MV Code Club.zip (520 KB)

If the pipes have a rigid body, ensure that Gravity is toggled off.

Thank you man, the problem is fixed. Do you know how to make the Score Text work by following ‘step 13’ in the instruction with my source code?

1 Like

I haven’t figured out how to apply the script to the gui because of the new unity update that came out messed with all the gui business so, basically that part is out of date. Just letting you know it’s not your fault.

havent tried or worked through this myself, but ill try and help a bit if I can.

depending how the score was working previously, did you have this added as a public GUIText object and then drag over to inspector?

if you did, and seeing that you have created the Canvas within your project. then ensuring that the canvas has a ‘Text’ object under it which effectively has the same characteristics as the GUIText as it has a text property.

within your pipespawning (im assuming thats the one that deals with scoring) script change the scoreText to be a ‘Text’ type as opposed to GUIText. and the rest should work.

so

var scoreText : Text;

In Unity 4.6 they introduced a new type called ‘Text’ it is part of the UnityEngine.UI namespace. Where ever you are trying to access the ‘Text’ type ensure you have imported the correct libraries.

using UnityEngine.UI; // This is for the UI C# (I am sure its the same with ‘import’ for UnityScript.)

Once you have the library imported change the GUIText to Text. To edit the string data in the text that gets displayed its really easy.

public Text ScoreText; // ScoreText is of type Text, in Unity go to GameObject->UI->Text and drag it here.

ScoreText.text = “New Text”; // You can edit the text here like this.

1 Like

Yup, it was declared a public varialbe:
var scoreText : GUIText;

That’s spot on, the type of scoreText is ‘Text’ which really should be GUIText, although, there seems no way to fix it.

Thank you man, you’re my hero. You just help me to complete my first game ever. Now I’ll publish it to Google Android, do you know how to do that?

1 Like

sorry completely forgot about the UI namespace, thats what i get for typing at 3am :frowning:

I have not yet, just iOS but I have used this to test if my apps work on Android although I have not yet deployed. There is a beta testing software that is free and OpenSource called TestFairy, using Eclipse and the ADT you can compile your Unity Android project and then compile to .apk and using TestFairy to have it test on Android devices.

Essentially what it does is allow you to be able to collect data about possible crashes etc. Its really easy to set up, just create an account get the emails of people you want to be your Beta testers and invite them to test your app.

Once your game is optimized putting your App in the Google Play store should be a breeze.

Hope this helps.