How to make a burst gun

So I am trying to make a burst gun but I have no clue how to code it. I already have some code for a semi and auto fire gun but just don’t know where to start with burst Help.
What I am trying to do is for the gun to fire 3 shots and then delay a sec.
Kind of like this…

This is the code I am building apon…

if( && this.canShoot === true && this.burst)
            result.entity.collision.entity.rigidbody.applyImpulse(, result.normal);
            this.currentAmmo -= 3;
        if( == 'Bean Boi')

can anybody help me plz…

Hi @Connor_Briggs! What is the problem you have with the code above? Or is that where you want to apply the delay?

The delay is the problem I have.
I have tried using the time-out thing in the forum below…

but i just could not get it to work using that.

I would use a counter because you want to do 3 shots in a row. I would also create a shoot function that you can call again after a small delay until 3 shots are fired. Something like below. (You can not copy and paste this code, it’s only to give you an idea of my logic).

// initialize function 
    this.counter = 0;
// update function
    // mouse pressed and burst is enabled 
    if (this.counter == 0) {
Script.prototype.burst = function(){
    // shoot
    this.counter += 1;

    if (this.counter != 3) {
        }.bind(this), 1000);
    else {
        this.counter = 0;

thx for the help…
i’ll try that idea and see if i can get it to work.

1 Like