gun spawn problems

hey guys i have a gun that i have given a rigidbody so that i can use my shoot scriptthis one

var projectile : Rigidbody; 
var speed = 2000; 
var savedTime = 10;

function Update() {
if( Input.GetButton( "Fire1" ) ){

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

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

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

}
}

this works i have sett the var speed to 0 save time also 0

but i want the gun to stay at its spawn point. i will use this to switch my gun becouse im gonna tweake the imput getbuttondown("fire1") to GetKeyDown ("1") so that when i press 1 the gun wil be spawned but as a alreddy asked how to let the gun stay at its spawnpoint??

thanks

You speak about spawning a gun and having it stay put but your code looks more like code for a bullet/projectile. (And speaking of which err... you haven't noticed the Rigidbody that this class creates is even called "projectile"?)

To spawn a gun first off: don't make it a rigidbody, rigidbody is affected by gravity and physics and such things.

Also you would not want to set it's velocity at all. `instantiatedProjectile.velocity = transform.TransformDirection( Vector3( 0, 0, speed ) );`

The line above is from your code, what it says is to make the Rigidbody you've just created on the line above have a movement in a direction, at the end you see the Vector3 to be set to 0, 0, speed. This means it will have a velocity on its z-axis to be the same as your var. "speed".

If I've not misunderstood you completly I'ld guess you aren't very experienced with programming yet and if that's the case I'ld strongly suggest you check out some tutorials to get to know atleast the basics. (Either go to your local library or google it, there are tons of 'em.)

Also you should go to Unity3d.com and check out their scripting manual and keep it close so you can have some reference on what methods and properties etc you can use. :)