Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

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

Discussion in 'Scripting' started by maxsoft, Dec 21, 2014.

  1. maxsoft

    maxsoft

    Joined:
    Dec 20, 2014
    Posts:
    4

    Attached Files:

  2. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    If the pipes have a rigid body, ensure that Gravity is toggled off.
     
  3. maxsoft

    maxsoft

    Joined:
    Dec 20, 2014
    Posts:
    4
    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?
     
    Polymorphik likes this.
  4. TheFreedomBird

    TheFreedomBird

    Joined:
    Dec 19, 2014
    Posts:
    8
    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.
     
  5. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    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
    Code (JavaScript):
    1. var scoreText : Text;
     
  6. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    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.
     
    OboShape likes this.
  7. maxsoft

    maxsoft

    Joined:
    Dec 20, 2014
    Posts:
    4
    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.
     
  8. maxsoft

    maxsoft

    Joined:
    Dec 20, 2014
    Posts:
    4
    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?
     
    Polymorphik likes this.
  9. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    sorry completely forgot about the UI namespace, thats what i get for typing at 3am :(
     
  10. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    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.