Im having another problem. Todays not my lucky day. Everytime I shoot a bullet it instantiates and falls to the ground but theres a trail thats left behind where the bullet is meant to be going but its not following. Im guessing its something to do with the box collider im not sure please help.
var BulletPrefab : Transform;
var BulletSpawn : Transform;
var BulletSpeed : int = 1000;
var BulletSound : AudioClip;
var ReloadTime : float = 5;
var MagCapacity : int = 30;
var MagCurrent : int = 30;
var NoBulletClick : AudioClip;
var ReloadSound : AudioClip;
function Start(){
MagCapacity = MagCurrent;
Debug.Log(MagCurrent);
}
function Update(){
if (Input.GetKeyDown("mouse 0") MagCurrent > 0)
{
-- MagCurrent;
audio.PlayOneShot(BulletSound);
Shoot();
Debug.Log(MagCurrent);
}
else
if (Input.GetKeyDown("mouse 0") MagCurrent == 0)
{
Debug.Log("No Ammunition");
audio.PlayOneShot(NoBulletClick);
}
else
if (Input.GetKeyDown("r") MagCurrent < MagCapacity)
{
Reload();
}
}
function Shoot(){
var bulletInstantiate = Instantiate(BulletPrefab, BulletSpawn.position, BulletSpawn.rotation);
bulletInstantiate.rigidbody.AddForce(transform.right * BulletSpeed);
}
function Reload(){
audio.PlayOneShot (ReloadSound);
yield WaitForSeconds (ReloadTime);
MagCurrent = MagCapacity;
}