Home Technical Talk

Rigging a TF2 Weapon

I'm trying to create a custom model for Team Fortress 2, in this case a very simple cylinder to replace the pyro's axe, just so I can learn the process. I've already made a hat for the workshop, so I have the basic process down. I've looked up endless amounts of tutorials, but none seem to successfully answer my question - in Blender, how do I rig my cylinder-axe so that ingame, when the pyro swings my cylinder follows?

I've decompiled the fireaxe, modeled my own replacement, then rigged my cylinder to the weapon_bone. That didn't work; the weapon floats around the pyro's head and never moves when he attacks. Next I tried importing in the entire pyro model, making my cylinder, and then rigging to the weapon_bone. Same result.

Basically, I'm making an item, and rigging it to the weapon_bone like all tutorials I've looked at say to do, but it doesn't work. Any help would be appreciated!

Replies

  • 16bit
    Options
    Offline / Send Message
    16bit polycounter lvl 13
    Did you export the Weapon bone as well?
  • Xuku
    Options
    Offline / Send Message
    Is the weapon bone exported separately, or would it (for example) be in my pyro_stick.smd? Because I am exporting the mesh pyro_stick, which is parented to the original weapon's armature and also has an armature modifier for weapon_bone. Do I need to modify my weapon's QC file?

    EDIT: After a bit more reading it looks like I'm gonna need to learn how to make my own .qc's and .vmt's. I think my hat worked because in itemtest I can automatically bind to bip_head, but otherwise (correct me if I'm wrong) I simply need to adjust my .qc file a bit to indicate the bone.
  • Xuku
    Options
    Offline / Send Message
    Sorry for the double post, but I've made progress and have a new question, and I didn't want to make a new thread.

    I've managed to put my custom shotgun model into TF2, but I can only see it from first person - on other characters it appears as the stock shotgun. Below is a screenshot, my .qc, and my .vmt.

    As you can see, I copied the decompiled shotgun's .vmt and .qc files and modified them to suit my needs, so I suspect I failed to make a certain change which is resulting in the stock shotgun being used for the world model. Any help would be much appreciated!

    pyro_shotty.qc
    $cd "***directory***\pyro_shotty"
    $modelname "player\items\pyro\pyro_shotty\pyro_shotty.mdl"
    $model pyro_shotty "pyro_shotty.smd"
    $cdmaterials "models\player\items\pyro\pyro_shotty"
    $cdmaterials ""
    $hboxset "default"
    $hbox 0 "weapon_bone" -1.249  -3.844  -45.559  1.254  4.971  34.888
    $hbox 0 "weapon_bone_1" -2.003  -2.277  -6.597  2.003  1.919  5.116
    $hbox 0 "weapon_bone_2" -0.613  -0.602  -1.662  0.620  0.631  1.491
    // Model uses material "models\player\items\pyro\pyro_shotty\pyro_shotty.vmt"
    $attachment "muzzle" "weapon_bone" 0.00 3.73 34.92 rotate -90.00 -0.00 0.00
    $attachment "eject_brass" "weapon_bone" -0.80 3.25 10.76 rotate -11.66 162.02 -167.64
    $surfaceprop "metal"
    $illumposition -6.167 0.000 0.564
    $sequence idle "pyro_shotty" fps 30.00
    $collisionmodel "pyro_shotty.smd" {
    
        $mass 4.8
        $inertia 1.00
        $damping 0.00
        $rotdamping 0.00
    }
    
    pyro_shotty.vmt
    "VertexLitGeneric"
    {
        "$baseTexture" "models\player\items\pyro\pyro_shotty\pyro_shotty"
        $BASEMAPALPHAPHONGMASK 1
    
        "$phong" "1"
        "$phongexponent" "25"
        "$phongboost" "12"    
        "$lightwarptexture" "models\lightwarps\weapon_lightwarp"
        "$phongfresnelranges"    "[.25 .5 1]"
    
        "$rimlight" "1"
        "$rimlightexponent" "10"    
        "$rimlightboost" ".175"
    
        "$glowcolor" "1"
    
        // Cloaking
        "$cloakPassEnabled" "1"
        "Proxies"
        {
            "weapon_invis"
            {
            }
            "ModelGlowColor"
            {
                "resultVar" "$glowcolor"
            }
            "Equals"
            {
                "srcVar1"  "$glowcolor"
                "resultVar" "$selfillumtint"
            }
            "Equals"
            {
                "srcVar1"  "$glowcolor"
                "resultVar" "$color2"
            }
        }
    }
    
  • 16bit
    Options
    Offline / Send Message
    16bit polycounter lvl 13
    No clue at all on why it shows the default shotgun as the world model. Try one of the newer c_model shotguns qc. The Reserve shooter might be one.

    Though I can see nothing in your qc file that suggests it would work any differently.
  • Xuku
    Options
    Offline / Send Message
    I'll try modeling my shotgun after the reserve shooter. It's rigged differently though, which I find strange - and its .qc file leaves out one of the bone binds that the default shotgun has. I guess I'll just experiment with it.

    Also, something interesting: in itemtest, when I choose for my cusotm shotgun to "replace" the default shotgun, it turns out like in the picture. But when I choose the reserve shooter, my custom model appears, only the shotgun shell is floating randomly (the rigging difference I mentioned).

    So I guess I know how to fix the problem (using the reserve shooter not the stock shotgun), although it bugs me to not know why it fixes it.

    EDIT: Can you help me understand the difference between c_models, v_models, and w_models?
  • 16bit
    Options
    Offline / Send Message
    16bit polycounter lvl 13
    v_model is the model you see in first person, and w_model is the model that appears on other players and yourself in third person. C_models are used in first and third person views.

    If you want to know about the code, then I have no idea. I've never tried replacing a weapon that wasn't a c_model.
  • Xuku
    Options
    Offline / Send Message
    Okay, thanks! I'm trying to replace the shotgun c_model, so I don't know why it uses the default shotgun instead of mine for the world model. Also, I have a question about the issue I mentioned with the reserve shooter: in first person, my model appears normally when I replace the reserve shooter (not the stock shotgun). But the worldmodel has parts floating randomly about, and I found out that the world model for shotguns use less bones than the first person view - how does this work if one c_model is supplied for both view and world models?

    To get a general idea of the process, how would you replace a weapon that was a c_model? I rigged to the c_model's armature, copied its .qc and .vmt, and edited ithem to my needs. Am I missing a step?

    EDIT: Something interesting, according to http://wiki.teamfortress.com/wiki/Team_Fortress_Wiki:3D_Models/Weapons the shotgun uses a w_model. Perhaps since I am supplying a c_model, when I replace the item in itemtest it supplies the default shotgun's w_model for the world model.
  • 16bit
    Options
    Offline / Send Message
    16bit polycounter lvl 13
    I am not a source expert, someone who is more knowledgeable may be of more help. But if you are going to be replacing a weapon that uses v and w_models, you gun probably needs to be a v and w_model too.

    Though that may not be the case either, I replaced the pyro's fire ax and it showed my model as I taunted.

    You may need to ask someone of the Steam forums or maybe FPS Banana. I've never made a weapon that wasn't melee yet.
  • Xuku
    Options
    Offline / Send Message
    Alright, thank you very much for your help!

    EDIT: Seems to work fine if I "replace" the reserve shooter in itemtest. For the heavy, I replace the family business, for the engi, the frontier justice. As far as I can tell, there is some hard-coded setting for the stock shotgun to use its w_model, so in itemtest I can't tell it to use mine - it only uses my c_model for the viewmodel. Luckily, each class that uses shotguns has a non-stock shotgun, and these work fine for itemtesting.

    I decided to post my results in case anyone else runs into this problem.
Sign In or Register to comment.