Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

GUI and text and what not

Discussion in 'Animation' started by Wallisch_pls, May 23, 2014.

  1. Wallisch_pls

    Wallisch_pls

    Joined:
    Oct 14, 2013
    Posts:
    13
    I'm some-what new to Unity, but it's starting to become easier to learn.

    I'm making a 2D game with the sample assets, everything works fine. I'm adding coins so they can pick up, i added a JS script to the "coin" and made it so it's destroyed when in contact with character. Now, the hard part is making the GUI/3D text make it = the var coin. I usually never ask questions unless troubled with severe confusion

    My Question:
    I have the GUI set up so it's always in the top right screen and follows with camera, but how do i make (var coin = 0;" equal to the text? Do i use "public" so it can be used in other scripts? where do i attach this script?

    What I have so far (this is attached to the "coin":

    [SUB]
    #pragma strict

    public var coin = 0;

    function OnTriggerEnter2D(info : Collider2D)
    {
    if (info.tag == "Player")
    {
    Destroy(gameObject);
    coin += 1;
    }
    }
    [/SUB]

    and then i dont know what to do, please help
     
  2. Wallisch_pls

    Wallisch_pls

    Joined:
    Oct 14, 2013
    Posts:
    13
    then i tried this, but of course didn't work:

    Code (csharp):
    1.  
    2. #pragma strict
    3.  
    4. function Start() {
    5.     var myInt = 7;
    6.     GUIText(myInt.ToString());
    7. }
    8.  
    9. function Update () {
    10.    
    11. }
    12.