Hi again!
I have a shoot java script that shoots a single Rigidbody at a time. is there a way to place an automatic function for
the harpoon script like a machinegun? if so, how do i do it?
this is my script:
var throwSound : AudioClip;
var harpoonObject : Rigidbody;
var throwForce : float;
var endTime : float;
var hitParticles : ParticleEmitter;
private var canShoot : boolean = true;
private var startTime = 0;
function Update () {
if(Input.GetButtonDown(“Fire1”) canShoot) {
//audio.PlayOneShot();
canShoot = false;
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)