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

How to make UI on gun? Unity 4.6

Discussion in 'Scripting' started by KyleStank, Nov 11, 2014.

  1. KyleStank

    KyleStank

    Joined:
    Feb 9, 2014
    Posts:
    204
    I was wondering like how to display the amount of bullets left in a magazine on a gun. Like in the Halo series, for the Assault Rifle, it displays the ammo in the current magazine and when you shoot it updates real time. I know how to make the amount of bullets and everything, the question is how do I make the text appear on the gun and follow the gun when it moves. I would love to have this feature on a simple game I am making. Also, I am kind of new to game development, I have been making games for like 11 months...
     
  2. Pysassin

    Pysassin

    Joined:
    Dec 27, 2012
    Posts:
    87
    If its just text you are looking for place a 3D Text object on the model then through script alter the text property to match the number of bullets. Because it is a GameObject it will follow its parents(aka the gun) through any animations giving you your desired effect.
     
  3. KyleStank

    KyleStank

    Joined:
    Feb 9, 2014
    Posts:
    204
    I would do this but I am using Unity 4.6 BETA. I only see "Text" which is in the Canvas. I hate the old UI and won't go back since I have experienced the new one.
     
  4. cmcpasserby

    cmcpasserby

    Joined:
    Jul 18, 2014
    Posts:
    315
    You could make a new canvas with a camera and have it render to a renderTexture and use that render texture on the screen of your model.
     
  5. KyleStank

    KyleStank

    Joined:
    Feb 9, 2014
    Posts:
    204
    Okay, I will try this. Thanks!
     
  6. cmcpasserby

    cmcpasserby

    Joined:
    Jul 18, 2014
    Posts:
    315
    Ya screen space - camera mode, won't work for a normal canvas