- Home /
Question by
ryan123321 · Feb 25, 2012 at 03:08 AM ·
guigunammo
gui help for ammo display
hello i am making a fps game and i was wondering how would I make it so it has a set number of ammo and a gui displaying the ammo count on the screen. in other words how to i make a gui and ammo count.
Comment
Answer by Tyler_TP3 · Sep 27, 2013 at 03:18 AM
var bulletHudTexture : Texture; //bullet display texture
var ammoCountRect : Rect = Rect(25,25,50,25);
var ammoStartX : int = 100;
var ammoY : int = 25;
var ammoSize : Vector2 = Vector2(2.316,15);
var ammoSpacing : float = 3;
function OnGUI ()
{
if (beingHeld)
{
for (var i : int = 1; i <= currentClip; i++)
{
GUI.DrawTexture(Rect(ammoStartX + ((i - 1) * (ammoSize.x + ammoSpacing)), ammoY, ammoSize.x, ammoSize.y), bulletHudTexture);
}
GUI.Label(ammoCountRect, currentClip.ToString() + "/" + currentExtraAmmo.ToString());
}
}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
having trouble with ammo reload script. destorys extra ammo 1 Answer
Gui text, ammo counter 1 Answer
GUI problem 1 Answer
Unity3D Game Time 1 Answer