How to make ammo reffil on pickup
this is my script for gun
static var ammo = 30;
static var health = 100;
static var maxAmmo = 120;
var key : String = "mouse 0";
var bullet : Rigidbody;
var speed : float = 1000;
function Update () {
if(Input.GetKeyDown(key)){
if(ammo > 1){
shoot();
}
}
}
function shoot(){
var bullet1 : Rigidbody = Instantiate(bullet , transform.position, transform.rotation);
bullet1.AddForce(transform.forward * speed);
ammo --;
}
function OnGUI () {
GUI.Label(Rect(10,10 , 250, 250 ), "ammo:"+ammo) ;
GUI.Label(Rect(80,10,250,250), "hp:"+health);
}
and this is my script for ammo
var playerTag = "Player";
function OnTriggerEnter (col : Collider) {
if(col.tag == playerTag){
shoot.ammo = shoot.maxAmmo;
}
}
I want that ammo in box wich is 120 and then + current ammo wich is ammo
Comment
Your answer
Follow this Question
Related Questions
AmmoScript.cs troubles... 1 Answer
Storing diffrent bullet amounts for different Weapons. 1 Answer
How can I add ammo to my gun script? 0 Answers
How to turn score points into ammo amount? 0 Answers
I am trying to increase my ammo 1 Answer