Adding Hitbox to Models without a Bone

edited January 2016 in Tutorials

If you tried some of Valve's prop models, you had already noticed that many of them don't have a hitbox, so they can't be used for selectable units.

Automate the process with this tool: https://github.com/MSre/Dota2-VMDL-Hitbox-Adder

There is a very easy process that takes no longer than a couple of minutes to add one.

In this tutorial, I will add a hitbox to this model: gryphon_statue001.vmdl

img

As you can see after selecting Display -> Hitboxes, it has no hitbox, so it can't be clicked on ingame.

Step 1. Hammer DMX Export

Open Hammer, make a new map, and drag the model into the origin.

img

You can also rotate or displace it if its required, as well as adding more models to the scene.

After its done, go to File -> Export Files or Export Selected, and save the file as .dmx inside the models folder.

Step 2. Generate a VMDL

Open the Model Editor and select New VMDL From Mesh File option, and choose your recently generated .dmx file

img

img

Save and close.

Step 3. Add Cube.dmx hitbox

This is a mesh with 1 bone. Download it directly from ModDota Resources and put the file in your model folder

Credits to @Internet_Veteran

Step 4. VMDL Editing

This is the critical part. Basically you'll be adding the cube mesh into the exported model. You can do this on the model editor (Animation -> Add Animation, or by editing the .vmdl file with a text editor and coping the following lines:

http://pastebin.com/qryMBaPz

Just replace everything on your vmdl except for the first big m_meshList block

Restart the workshop tools after that.

Step 5: Open the file and adjust the hitbox

The attached cube is a small 50x50 rectangle, just click on it and adjust it to your model needs. You can also edit it directly from the .vmdl file under m_vMinBounds and m_vMaxBounds

Note: If your file shows as error, make sure to restart the workshop tools, or repeat the process after deleting all the compiled and source files.

Press T hotkey to access the scaling tool.

https://puu.sh/lLIJ3/bed9e07b6f.jpg img

img

That's all! Now your model will have a hitbox ingame:

The concept of Modding Community doesn't go well together with Competitive Business
My Project Page || My GitHub Profile ||

Comments

  • All hail cube.dmx

  • I haven't tried this yet but could same cube.dmx be used to (by renaming the hitbox) be used for adding the other hitboxes as well? (for use with particles.)

  • edited December 2015 Posts: 1,667

    What other hitboxes? For particles, creating the new model lets you add as many attach points as you want, generally at least attach_hitloc and attach_attack1

    The concept of Modding Community doesn't go well together with Competitive Business
    My Project Page || My GitHub Profile ||

  • Particle systems can be created to use some hitboxes. For example "hands" or "head".

  • When I try to follow this, the model editor saves my vmdl file with a kv3 format instead of the schema text format you seem to get: http://hastebin.com/efapegebef.scala

    As a result, pasting the data you provided does not work.

    Any idea why this is happening? Or how I would do this from within the Model Editor instead?

  • Posts: 25

    I'm also seeking more info on how to do this within the text editor.

    I am encountering the same issue as rap_game_anti_mage.

  • edited December 2015 Posts: 1,667

    Try Model -> Mesh -> Add Mesh

    img

    The concept of Modding Community doesn't go well together with Competitive Business
    My Project Page || My GitHub Profile ||

  • Posts: 1,667

    Edit: I see the encoding changed. You have to Animation -> Add Animation with the Cube now. Editing the guide to reflect this

    The concept of Modding Community doesn't go well together with Competitive Business
    My Project Page || My GitHub Profile ||

  • edited December 2015 Posts: 2

    I made a program that will automatically add cube.dmx to a .vmdl file provided that it is in the kv3 encoding. It also preserves the mesh structure unlike copy/pasting the pastebin. https://github.com/MSre/Dota2-VMDL-Hitbox-Adder

  • Posts: 808

    If you're going to use a GitHub to host it why not put the source on there as well? o.O

    MAKE CUSTOM GAMES GREAT AGAIN

    Finished-
    kv checker - https://arhowk.github.io
    panorama video series - https://moddota.com/forums/discussion/2021/inclusive-panorama-tutorial-quest-box

    My pet project This Cursed World/Crestfallen (name pending)
    https://moddota.com/forums/discussion/986/this-cursed-world-rpg#latest

  • Added the source.

  • I can't seem to be able to move or rotate the hitbox area (only scaling is possible). Are the other two functions locked?

  • @cowsforyou on left pane, select "Box Scale" after selecting the hitbox. You have more freedom in this mode (btw, you can't rotate it, as far as I know).

  • Posts: 213

    This tutorial seems to be aimed mostly at static mesh props. Is there any way to do this for animated models or models with moving pieces?

  • Posts: 107

    Shouldnt animated models already have skeletons?

    sunshine, hurricane

    all the highs & lows

  • Posts: 213

    While they do have skeletons, the problem I'm running into is that it doesn't have a hitbox. Since all of the models that come with the tools are pre-compiled, I can't just add the hitbox. Following this guide's process causes the animations to be lost and combines all of the separate meshes into one static mesh. I guess what I really need would be a full .vmdl_c decompiler, but I don't know if that's been done yet.

  • Posts: 87

    When I'm click Add Animation -> Cube.dmx it's just freezes over

  • Posts: 57

    I've also run through this tutorial, trying some of the various alternatives, but I can't seem to get it to work. I've even tried a few ideas that were not mentioned here, such as making a vmdl out of the cube just to see if something might kick it into action.

    The error I keep hitting is the inability to load the reference animation.

    [ W ModelProcessingSystem  ]: LoadAnimationFile(204): Failed to load animation file, "models/Cube.dmx"
    [ W ResourceCompilerSystem ]: Couldn't load reference animation: "models/Cube.dmx"
    [   ResourceCompilerSystem ]:                                                                       [FAIL]
    [ W ResourceCompilerSystem ]: CResourceCompilerModel::CompileResource( "C:/Program Files (x86)/Steam/steamapps/common/dota 2 beta/content/dota_addons/beta_test/models/teleport_base.vmdl" ): CreateChildContext( "models/teleport_base_eb459cc8.vagrp" )->CompileImmediately() Failed
    [   ResourceCompilerSystem ]:                                                                       [FAIL]
    

    Tried a dozen times through the various methods, tried altering things slightly based on various comments in this thread. Nothing I can do can get Cube to load. :(

  • Posts: 57

    Thanks to Yunten I have gotten this to work now!

    1. Extract model per guide.
    2. Create VMDL. (Don't close per guide.)
    3. Animation -> Add Animation -> cube.fbx (cube.fbx found here, to be added to Resources)
    4. Skeleton -> cube (Right Click) -> Add Hitbox
    5. Hitboxes -> list 0 -> default -> cube scale to desired size. (Sometimes I have to set the Bounds to -50, -50, -50 and 50, 50, 50 otherwise the scale drag doesn't work.)

    The current cube.dmx gave me problems, always erroring when adding it to the vmdl, with both the the copy/paste method and the add animation method.

    Note, something that I missed for a while was that this will never work with prop_dynamic or prop_static. While it may be obvious, it took me a while to figure that out. Need to create a unit, and use the vmdl as the unit's model.

  • Posts: 69

    Thanks Sarynth, I was wondering why what I had been doing suddenly wasn't working