How can I script my ammo to where my ammo will add to the remaining ammo like in call of duty or halo. my current script is :
var projectile : Rigidbody;
var ammo : float = 10;
private var maxammo : float = 10;
private var leastammo : float = 0;
var ammostored : int;
private var noammo : int = 0;
private var NoClips = false;
private var empty = false;
private var reloading = false;
var initialSpeed = 20.0;
var pos : Vector2 = new Vector2(20,40);
var size: Vector2 = new Vector2(Screen.width / 2 ,20);
var posClips : Vector2 = new Vector2(20,40);
var sizeClips: Vector2 = new Vector2(Screen.width / 2 ,20);
var TextStyle : GUIStyle;
function OnGUI(){
GUI.Label(Rect(pos.x,pos.y,size.x,size.y)," " + ammo, TextStyle);
GUI.Label(Rect(posClips.x,posClips.y,sizeClips.x,sizeClips.y),"/" + ammostored, TextStyle);
}
function Fire () {
var instantiatedProjectile : Rigidbody = Instantiate (projectile, transform.position, transform.rotation);
instantiatedProjectile.velocity = transform.TransformDirection(Vector3 (0, 0, initialSpeed));
}
function Update ()
{
if (Input.GetMouseButtonUp(0) && ammo > leastammo){
Fire();
ammo -= 1;
}
if (ammo >= maxammo){
ammo = maxammo;
}
if (ammo 0){
ammo = maxammo;
}
if (Input.GetMouseButtonUp(1) && empty){
ammostored -= 10;
empty = false;
}
}
function LateUpdate (){
if (reloading){
ammo = maxammo;
}
if (NoClips){
}
}
function addclipssmall (){
ammostored += 10;
}
function addclipsmedium (){
ammostored += 20;
}
function addclipslarge(){
ammostored += 50;
}
this also handles some ammo pick up and fireing bullets thank you for any help
Tracey Pitloun