We have a problem with the bullet collision with the target. if the bullets force is above 1000, then the target does not register the collision. If we make the force <999 then it registers the collision, however visually it seems the bullet does not seem like a fired bullet. Please suggest how we can maintain speed and still register the collision
the following script was added to the target
var targetRoot : GameObject;
private var beenHit: boolean = false;
var hitSound : AudioClip;
var UpSound : AudioClip;
function OnCollisionEnter(theObject : Collision)
{
if(beenHit==false && theObject.gameObject.tag=="bullet")
{
audio.PlayOneShot(hitSound);
targetRoot.animation.Play("down");
beenHit=true;
TargetControll.tgtdwn++;
}
}
function Update ()
{
}
And the following script was added to the gun
static var canshoot = true;
static var canreload = false;
var BulletPrefab: Transform;
var DeagleSound : AudioClip;
var DeagleReload: AudioClip;
function Update ()
{
var deagle = GameObject.Find("desert eagle");
if(Input.GetButtonDown("Fire1") && canshoot==true)
{
var Bullet = Instantiate(BulletPrefab, GameObject.Find("BulletSpawn").transform.position, GameObject.Find("Main Camera").transform.rotation);
Bullet.rigidbody.AddForce(transform.forward * 9000);
if(Indepvariable.charge <= 6)
{
canshoot = false;
deagle.animation.Play("shootfix");
audio.PlayOneShot(DeagleSound);
weaprecoil ();
}
}
if(Indepvariable.charge == 7)
{
canshoot = false;
deagle.animation.Play("reload");
audio.PlayOneShot(DeagleReload);
reload ();
}
if(Input.GetButtonDown("reload") && canreload == true)
{
canshoot = false;
deagle.animation.Play("reload");
audio.PlayOneShot(DeagleReload);
reload ();
}
}
function weaprecoil ()
{
yield new WaitForSeconds (0.5);
Indepvariable.charge++;
canshoot = true;
}
function reload ()
{
Indepvariable.charge = 0;
yield new WaitForSeconds (3);
canshoot = true;
canreload = false;
}