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; //What will be shot out
var BulletSpawn : Transform; //Place a empty game object in front of gun, this will act as Bullet Spawn
var BulletSpeed : float = 1000; // The speed in which the bullet flies
var BulletSound : AudioClip; //The sound when a bullet is fired
var ReloadTime : float = 5; //The time it takes to reload a bullet
var MagCapacity : int = 30; //The amount of bullets a magazine can hold
var MagCurrent : int = 30; //The Starting amount of bullets
var NoBulletClick : AudioClip; //The noise the gun makes when there is no more ammo
var ReloadSound : AudioClip; //The reload sound the gun makes, (Recommended it is as long as the reload time)
var IsReloading : boolean = false; //Keep this off, this makes sure that the gun cannot be shot while reloading
function Start(){ //This function makes us start with the maximum amount of bullets we are allowed and tells us that it is working
MagCapacity = MagCurrent;
Debug.Log(MagCurrent);
}
function Update(){
///////////////////////////////////--Shooting--////////////////////////////////////////////////////
if (Input.GetKeyDown("mouse 0") MagCurrent > 0 IsReloading == true)
{
}
else
if (Input.GetKeyDown("mouse 0") MagCurrent > 0 IsReloading == false)
{
-- MagCurrent; //This deducts 1 from our current magazine
audio.PlayOneShot(BulletSound); //Makes a bullet sound
Shoot(); //Starts the function to shoot bullets
}
///////////////////////////////////--No Ammunition--////////////////////////////////////////////////////
if (Input.GetKeyDown("mouse 0") MagCurrent == 0 IsReloading == true)
{
}
else
if (Input.GetKeyDown("mouse 0") MagCurrent == 0 IsReloading == false)
{
Debug.Log("No Ammunition");
audio.PlayOneShot(NoBulletClick);
}
///////////////////////////////////--Reloading--////////////////////////////////////////////////////
if (Input.GetKeyDown("r") MagCurrent < MagCapacity IsReloading == true)
{
}
else
if (Input.GetKeyDown("r") MagCurrent < MagCapacity IsReloading == false)
{
Reload();
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function FixedUpdate(){
if (Input.GetKeyDown("mouse 0") MagCurrent > 0)
{
Debug.Log(MagCurrent); //Shows how many bullets left we have in the console, I chose to put this function here because it will make sure there is no delay on the console. 0.02 Seconds
}
}
function Shoot(){
var bullet = Instantiate (BulletPrefab, BulletSpawn.position, BulletSpawn.rotation);
bullet.Rigidbody.AddForce(0,0,BulletSpeed);
}
function Reload()
{
IsReloading = true;
audio.PlayOneShot (ReloadSound);
yield WaitForSeconds (ReloadTime);
MagCurrent = MagCapacity;
IsReloading = false;
}