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

Counter on screen for gameplay?

Discussion in 'Scripting' started by corinne44, May 7, 2014.

  1. corinne44

    corinne44

    Joined:
    May 6, 2014
    Posts:
    9
    UHHH I guess I knew ahead of time that there was no way to create this game without coding :evil: I'm making a game for physics class and it's basically going to be Jimmy Neutron running around this map I made and jumping off buildings of different heights while going at different velocities. Jimmy's life is essentially in the player's hand as they decide which buildings are safe to jump off of (landing in a pool) and which are not. So is there any way to show a counter on the screen of the height of certain objects in Unity (predetermined measurements assigned to certain objects by ME in production) or of the velocity at which your the character is going at(speed being determined by the constant motion of the character)??

    Some example of games that use some kind of counter to determine the speed of your player (Nexuiz) heh that's all I can think of at the moment.

    If my question is confusing please tell me ;.; I need help! I've never used Unity before, but I know some basic Java as I'm in a CS class
     
  2. Patico

    Patico

    Joined:
    May 21, 2013
    Posts:
    886
    C# code to display something on screen:
    Code (csharp):
    1.  
    2. public class MyCounter: MonoBehaviour
    3. {
    4.    public float counter = 0;
    5.  
    6.    void OnGUI()
    7.    {
    8.       GUI.Label(new Rect(10, 10, 100, 100), counter);
    9.    }
    10. }
    11.  
     
  3. Patico

    Patico

    Joined:
    May 21, 2013
    Posts:
    886
    This is the same, but showing height
    Code (csharp):
    1.  
    2.     public class MyCounter: MonoBehaviour
    3.     {
    4.        public float scale = 1;
    5.      
    6.        void OnGUI()
    7.        {
    8.           GUI.Label(new Rect(10, 10, 100, 100), transform.position.y * scale);
    9.        }
    10.     }
    11.  
     
  4. corinne44

    corinne44

    Joined:
    May 6, 2014
    Posts:
    9
    Also, (sorry for asking so much of you but you seem so knowledgable :) ). Do you know how to import .mlt and .obj into Unity and make it the Third or First Person controller?