Results 1 to 9 of 9
  1. #1
    Iron Guard
    Join Date
    Mar 2004
    Posts
    620

    Default How do I make 2 weapons fire (alternating fire)

    The FireBlade has two sidemounted cannons:


    I need to be able to make them alternate fire (left, right, left, right, etc.) . I've tried the VTM method of using tick, and it didn't work - the guns fired basically simultaneously. One of the issues is that the Raptor code already has a Tick function in it to run the streamers/thrusters.

    How can I make the guns fire with even intervals without using tick?

  2. #2
    MSgt. Shooter Person
    Join Date
    Mar 2003
    Posts
    353

    Default

    You could cheat and throw a counter in tick. Or 2, leftCounter and rightCounter.

    Then when you fire, you could zero the counters, and not allow them to fire until they reach some given amount. Start one of the counters at 0, and one at the arbitrary amount. Then only increment the counters when the vehicles are firing.

    Actually, does weapon firing for weapons have firecount like player weapons? You could fire the left one if the firecount % 1 = 0 and right right one if firecount % 1 = 1.

    Think that would work?

  3. #3
    Iron Guard
    Join Date
    Mar 2004
    Posts
    620

    Default

    Could you give me a code sample? My coding is very, VERY weak. I'm a modeller/designer/texturer, not a coder, but I really want to get this working soon since BigCheese (my usual coder) is currently swamped with MSU stuff.

  4. #4
    MSgt. Shooter Person
    Join Date
    May 2004
    Posts
    93

    Default

    An easy way to get them to fire like that is to copy how the manta fires. If you look at the manta code(hoverbike) you'll see that it fires from one bone(look in the default properties at the bottom of the class), and has a dual fire offset. It looks like what you have isn't too complex(i.e. doesn't have 30 animations to export), so it' prolly would be to much to add a bone center (from the front view) of the places you want it to fire. Then export/import. There is a lot of things that use the cheap dual fire which looks like what you could use there.

  5. #5
    Iron Guard
    Join Date
    Mar 2004
    Posts
    620

    Default

    Thanks, CIpen, but the cannons on this vehicle are both individual weapon spawns (like the FlakRat or the Buggy in the VTM's). They each rotate and pivot. Each gun also has a firing animation (only one, and it's only 10 frames).

    I'm well aware of the DualOffset (it's what I used on the NodeRunner), but I really wanted both guns to move and rotate (I didn't want to take the cheaper way out ).

  6. #6
    Skaarj
    Join Date
    Sep 2003
    Posts
    20

    Default

    To implement a dual fire you're going to have to keep track of which gun you're going to fire with. with this decided, you should be able to just do an if check and call a different spawnprojectile function based on the outcome. You could even just modify your spawn projectile to do the dual firing instead.

    var bool bFireGun1;

    if( bFireGun1 )
    {
    Spawn(blah,...,Gun1.location);
    }
    else
    {
    Spawn(blah,...,Gun2.location);
    }

    In the case of instant fire, you're going to want to implement this directly into you're fire() function.

    I suppose if you need to implement some custom interval thing as well you'd want to put a check in your fire function, right before you actually spawn the projectile that says.

    if( Level.TimeSeconds > lastFireTime + TimeToWait )
    {
    lastFireTime=Level.TimeSeconds;
    SpawnProjectile();

    *Edit* bFireGun1=!bFireGun1;
    }

    In this block, bFireGun1=!bFireGun1 will make the above spawnprojectile function alternate which location to fire from

    obviously this could be expanded to take into account any other factors you may have as well.

    BTW, the model looks neato keen. If this helps maybe you could consider my post in this thread: New Turret Models Needed
    Last edited by legacy-SirBeefsalot; 07-22-2004 at 09:08 AM.

  7. #7
    MSgt. Shooter Person
    Join Date
    Jan 2004
    Posts
    221

    Default

    if you put this somewhere effectively

    var int i;

    if(i%2==0)
    {
    fireLeft();
    }
    else
    {
    fireRight();
    }

    i++;

    that will do fireLeft for all the even values of i and fireRight for all the odd values of i.
    maybe you could something like that in a timer.

  8. #8
    Skaarj
    Join Date
    Sep 2003
    Posts
    20

    Default

    Although that is true. As long as you are using just "i%2" i would stick to using a boolean value;

    var int i;
    var bool someBool;

    i %2 will always result in a 1 or a 0.

    "I+1" will always cause the result of "i%2" to be the opposite to that of "i"

    someBool = !someBool; gives the same result, and it just looks so much prettier. IMO.

  9. #9
    MSgt. Shooter Person
    Join Date
    Mar 2003
    Posts
    353

    Default

    Yeah, the reason I suggested using % is because firecount is a variable that already exists. Although Im not sure if it does in vehicle weapons. In "normal" weapons, firecount is incremented during the PlayFire() function (I think).

    So by using firecount % 1, the firecount variable is already in place, and is already incremented by other functions.


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.