Double shot...

Hi all , i have a doubt…i have this scrip in a empty gameobject for firing a bullet(rigidbody) its works fine, but if i duplicate de game object an move it beside the first gameobject like a 2 Guns shotgun…not fires well.

One single fires excelent…2…not firen nothing or firing wrong?

What can be?
Thanks in advance.

The script:

using UnityEngine;
using System.Collections;
public class disparosyrecargosnave : MonoBehaviour {
public Rigidbody Bala;
public float Velocidad = 80;
public float municion = 10;
public Animation reload;
float municionderecargo = 10;
public float municiontotal = 200;
///public static float municiontotal = 150;
public disparosyrecargos2 MyScriptShoot;
public float Conteo = 0;
public GUIText guimuni;
public GUIText guitotal;
public GameObject destello;
//public GameObject manoanim;
public GameObject expulsabalas;
public AudioClip recarga;
public AudioClip gunShot;
public AudioClip vacio;
void Start (){

destello.active = false;
}

void Update (){

guimuni.text = "Balas " + municion.ToString();
guitotal.text = "Total Balas " + municiontotal.ToString();

     if (Input.GetButton("Fire1")){
    //if(Input.GetMouseButtonDown(0)){   
          Conteo = Conteo + 1;
         
     if(Conteo > 15){
    
      Conteo = 0;
}   
     if(Conteo == 15 && municion > 0 && municiontotal >= 0){
            
         
        Rigidbody clone;
        clone=Instantiate(Bala, transform.position, transform.rotation) as Rigidbody;
        clone.velocity = transform.TransformDirection(Vector3.forward * 400);
        municion -= 1;
           Destroy (clone,1.0f);
        GetComponent<AudioSource>().PlayOneShot(gunShot);
       
}
}
    if(Input.GetKeyDown("r") && municiontotal > 0 && !Input.GetMouseButton(0) && !Input.GetMouseButton(1)){
    reload.Play("pistolamueve");
    municion = 0;
    Invoke ("recargando",2);
     AudioSource.PlayClipAtPoint(recarga, transform.position, 1);
 
}

    if(Input.GetButton("Fire1")){
   
    destello.active = true;
}
    else
    if(Input.GetMouseButtonUp(0)){
    destello.active = false;
}   
    if (municion <= 0){
    if(Input.GetButton("Fire1")){
    expulsabalas.SetActive(false);
    AudioSource.PlayClipAtPoint(vacio, transform.position, 1);
    destello.active = false;
}   
}
}
void recargando (){
   
   
    expulsabalas.SetActive(true);
    if(municiontotal > 0){
    municiontotal -= municionderecargo;
    municion += municionderecargo;

}
    if (municion > municionderecargo){
    municion = municionderecargo;
}
}
}

I can’t read the script you posted because the references being foreign words removes all sense of context from them, but I do see that you’re instantiating a rigidbody (a component) and not a GameObject. This likely isn’t going to work how you think it is. I would suggest making a GameObject with the rigidbody component attached (the bullet), and then making it a prefab. Drag your “bullet prefab” into your gun prefab as a public member and then be sure to “apply”, then in your script instantiate the whole bullet object, not just one script. The rigidbody needs a GameObject to move, after all.

Thanks for the reply Lysander, i was doint like you said, first atached the rigidbody i make a prefab and then dra it in to the ispector but also dont works :frowning: