Anti player guns or weapons

i have a simple launch code here…

var projectile : GameObject;
function Update () {
if (Input.GetButtonDown (“fire1”)) {
Instantiate (projectile, transform.position, transform.rotation);
}
}

how can i get my projectile to fire by itself in a slow repetetive manor?

First off, you should put your script in code tags so it’s easier for us to read.

As far as answering your question, the script reference is your friend: http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.InvokeRepeating.html

You should be able to figure things out from there.

great thanx…

now how can i get this code to shoot by trigger not by button:

The Tutorials teach you lots of stuff as well as the doc.

function OnTriggerEnter() {
    // Shoot code
}

Thank you all for the help.

ok how can i modify this code for the trigger command?

var throwSound : AudioClip;
var harpoonObject : Rigidbody;
var throwForce : float;
var endTime : float;
var hitParticles : ParticleEmitter;
var TimeBetweenShots : float;
private var untilNextShot : float;

private var canShoot : boolean = true;
private var startTime = 0;

function Update () {

untilNextShot -= Time.deltaTime;
if(Input.GetButton(“PushCannon”) untilNextShot <= 0 canShoot) {
//audio.PlayOneShot();
untilNextShot = TimeBetweenShots;

startTime = Time.time;
var newHarpoon : Rigidbody = Instantiate(harpoonObject, transform.position, transform.rotation);
newHarpoon.name = “harpoon”;
newHarpoon.rigidbody.velocity = transform.TransformDirection(Vector3(0,throwForce,0));
Physics.IgnoreCollision(transform.root.collider, newHarpoon.collider, true);
}

if((Time.time - startTime) > endTime) {
canShoot = true;
}
}

@script RequireComponent(AudioSource)

This is untested but try changing…

function Update {
//code...
}

to

function OnTriggerEnter (tri : Collider) {
//code...
}