i am trying to make a gun and i need some help with coding
hears my script so far
#pragma strict
var bullet : Rigidbody;
var power : float = 1500;
var damage : float = 100;
var reloadtime : float = 4;
var magcount : float = 10;
var magbulletcount : float = 21;
function Start () {
}
function Update () {
if (Input.GetButtonDown("Fire1")){
var instance: Rigidbody = Instantiate(bullet, transform.position, transform.rotation) as Rigidbody;
var fwd: Vector3 = transform.TransformDirection(Vector3.forward);
instance.AddForce(fwd * power);
}
}
as you can see i have got a bullet to instantiate and being able to change the force of the bullet sorted
but i need help with the rest
i want it so when the bullet mag count = 0 then it waits the reload time and the mag count goes down by one and when the mag count = 0 i want it so you carnt shoot anymore im not asking for somebody to finish the script but does anybody know like a tutorial?