Bullet Positioning

I have several weapons in my game, and im starting to make it so they can shoot. I have a Desert Eagle which works fine, but then I have an F2000 that shoots, but the bullets are instantiated somewhere below the camera. I attached the script to the actual gun object, and used the same script as the Deagle, except modified to create an F200 bullet. I will link the script below, but I do not know why the F2000bullet is being made at a different position than the Deaglebullet, even though the 2 scripts are identical.

var projectile : Rigidbody;
var initialSpeed = 20.0;
var reloadTime = .2;
var ammoCount = 60;
var clipsize = 30;
private var lastShot = -10.0;

function Fire() {

    if (Time.time > reloadTime + lastShot && clipsize > 0)
    {
        var instantiatedProjectile : Rigidbody = Instantiate (projectile, transform.position, transform.rotation);

        instantiatedProjectile.velocity = transform.TransformDirection(Vector3 (0, 0, initialSpeed));

        Physics.IgnoreCollision( instantiatedProjectile.collider, transform.root.collider);

        lastShot = Time.time;
        clipsize--;
    }
}

Check the transform gizmo / root node / pivot point of the F2000 GameObject. Instantiating the bullet at 'transform.position' via a script attached to the gun means that it will be spawned in a different place for each gun.

You could expose a public Vector3 on the gun script to define a relative position for the bullets to be instantiated from.

public var barrelPosition : Vector3;  // relative position of the barrel from the transform root

When you select one of the guns (that has this script attached), the barrelPosition will appear in the Inspector.

Then on the line where you instantiate the bullet, change it to:

var instantiatedProjectile : Rigidbody = Instantiate (projectile, transform.TransformPoint( barrelPosition ), transform.rotation);

When you fire the bullet, the position is determined by TransformPoint (the position of the gun with the local, relative position of the barrel applied). Tune the barrelPosition to get it to a point you're happy with.

Thank you so much for you're time in helping me out, its nice to get an answer every once in awhile thats actually helpful and persistently helpful, rather than "use a public variable. search the forums first next time." :) Thank you a great much!