Revision Difference
Importing_Rust_Weapon_Models#529941
<cat>Dev.Model</cat>
<title>Importing Rust Weapons</title>
While this isn't directly useful to anyone outside of Facepunch, I'm creating this guide here because I think it might be indirectly useful.
# Copying Source Files
I don't want to end up with a load of odd named files, so I'm going to spend some time to rename and organize the source files.
We're going to give everything a rust_* name. Viewmodel shit start with v_.
We're going to give everything a rust_* name. Viewmodels here start with v_.
<upload src="1/8d8d42ac983ca74.png" size="16917" name="image.png" />
Animations are going to start with the name of the model they're for. They're going to be all lowercase.
<upload src="1/8d8d42afcc0f89a.png" size="38031" name="image.png" />
Same with sounds
<upload src="1/8d8d42b1cef4270.png" size="35808" name="image.png" />
With textures things are generally a lot easier here if you name them properly from the start. Source 2 likes the files to have _color, _normal, _rough, _ao, _trans etc on the end. It's a naming convention that we should try to stick to too.
<upload src="1/8d8d42b7308fd93.png" size="8153" name="image.png" />
# World Model
The World Model is what we see in the player's hands in third person. It's also the model that appears in the world when the weapon is dropped.
1. Open ModelDoc
2. Add > Add Meshes
3. Find your regular weapon mesh [PAIN POINT: Allow Drag + Drop meshes from explorer?]
4. Click Compile
5. Save your vmdl (we're saving as rust_shotgun.vmdl).
You should now have an un-materialed weapon model.
<upload src="1/8d8d42ca2fcbb00.png" size="125463" name="image.png" />
6. Duplicate (or copy and paste) your .fbx in the list, for each LOD.
7. Rename them and select the meshes for each LOD.
<upload src="1/8d8d42ceb32be0d.png" size="29052" name="image.png" />
8. Add > LOD Group.
9. Duplicate the group, or do Add again, assign your meshes to the LODs properly.
10. Play with the Switch Threshold (especially the camera button) to set the lod distances. You'll need to compile to actually see the results.
## Material
1. Add > Default Material Group
2. Open Material Editor [PAIN POINT: Should Right click texture in asset browser > Create Material]
3. File > New [PAIN POINT: Too Many Shaders]
4. Save in your textures folder
5. Fill in your textures, set your material up. [PAIN POINT: pressing down arrow from the texture browser search box should select the first texture in the list]
<note>You might have to edit your rust _specular texture to make it a _rough texture. Open it in photoshop, copy the alpha channel to the rgb channels, invert it, delete the alpha channel.</note>
6. Go back to ModelDoc, set the material in your DefaultMaterialGroup
<upload src="1/8d8d42f8116b774.png" size="213487" name="image.png" />
## Physics
1. Add > Physics Shape Capsule
2. Select Root Bone (or none if none)
3. Place a few shapes to cover a decent amount of the weapon.
<upload src="1/8d8d42fd979a496.png" size="168548" name="image.png" />
<note>You could use boxes or spheres too, but you have to think about how it's going to act when it gets dropped. If you encase it in cubes it might end up balancing on the end of the barrel. With capsules it's going to fall flat whatever happens.
One thing to keep in mind here is that if you only use one capsule, it's going to be rolling around like a cucumber.</note>
## Attachments
1. Create an attachment for the muzzle flash to come out of. Call it muzzle.
<upload src="1/8d8d4307cbff984.png" size="315259" name="image.png" />
<note>RED on the axis is FORWARD. The way to remember this is to remember FLU and RGB. Front, Left, Up - Red, Green, Blue.</note>
2. Create a bone called "r_hold". This is what will be bonemerged with the player model to place it in the player's hands. Make sure to tick "Do Not Discard" in the property editor for the bone. [PAIN POINT: Need to lock this shit down and formalize it properly] [PAIN POINT: Do Not Discard should be on by default]
<note>Don't worry about getting this shit perfectly placed. Once you load the model in game you can fuck with it in ModelDoc and the changes will be hotloaded, so you'll be able to iterate super fast.</note>
## Debiggerfying
<upload src="1/8d8d431e7d72ec7.png" size="564639" name="image.png" />
If your gun is huge, select your mesh in the RenderMeshList tree and change the Import Scale. In my experience, things coming from Rust either need to be 0.1 or 0.6, but set it to what feels right.
Our player model's is a fat handed twat so you're never going to get things to line up perfectly, so just get it as good as you can.
<upload src="1/8d8d432c2fd7d24.png" size="789952" name="image.png" />
# View Model
Repeat the steps for the viewmodel model, except you don't need to add physics stuff. It should probably use the same material too.
1. Set the hands material (search for rust_hands)
2. Set Muzzle attachment (make sure the parent bone is on the barrel of the gun)
3. Add > Simple Animations
4. Select all the v_ animations
5. Drag the idle animation to the top
## Animgraph
1. Copy and and paste the v_*.vanmgrph from another weapon
2. Name it v_[weaponname].vanmgrph
3. Click the magnifying glass next to Graph: and select it
4. Click Edit next to Graph:
5. Click the Cog opposite Preview on the top right (you might need to make the column wider)
6. Select your v_ model here
7. Fix the animations on the nodes with the old weapon's name (v_oldweapon@idle etc)
8. Save and close
<warning>If the hands are all stretched and fucked I don't know what the problem is, it might be a source art issue</warning>
## Positioning
When positioned in game the view model should already be kind of positioned in the right place, but because of the foc differences you might want to tweak it.
1. In ModelDoc, Add ModelModifier_Translate
2. Change the model position offset while watching in game
<note>This sucks, we should really have some viewmodel meta and be able to preview it in modeldoc as it'll show in game.</note>