x


Please help with Turret rate of fire

So I have been having some trouble with shooting in unity not button shooting but AI shooting. I followed TornadoTwins tutorials on the turret but wanted some units to shoot faster or slower than others, but found that I couldn't change anything that would change rate of fire. so I tried a lot of stuff skipping boring story....

so over all I came to use this script:

var Turret : GameObject;
 var Bullet : Transform;
var BulletSpeed = 5000;
 var Character : Transform;
 var SavedTime = 0;

 if(Vector3.Distance(Character.position, transform.position)>20)
 {
var Shoot : AnimationEvent = new AnimationEvent();
Shoot.time = 2.166;
Shoot.functionName = "SHOOT";

Turret.animation.clip.AddEvent(Shoot);

}


function SHOOT ()

{
var bullet = Instantiate(Bullet, transform.Find("X").transform.position, Quaternion.identity);
bullet.rigidbody.AddForce(transform.forward * BulletSpeed);


}

Now this works just fine but it shoots twice any suggestions on making it shoot once?

Thanks Guys~

K.N.

more ▼

asked Aug 21 '10 at 12:36 AM

kyle gravatar image

kyle
58 6 6 10

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Okay this is closed guys the answer was that I had to work with the event position in the time of the shot apparently I had two animationEvents during the actual playing of the game because of the Shoot.time = 2.166;

more ▼

answered Aug 21 '10 at 02:40 PM

kyle gravatar image

kyle
58 6 6 10

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3726
x172
x45
x44

asked: Aug 21 '10 at 12:36 AM

Seen: 1498 times

Last Updated: Aug 21 '10 at 02:50 PM