Importing Rust Weapons
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. Viewmodels here start with v_.
Animations are going to start with the name of the model they're for. They're going to be all lowercase.
Same with sounds
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.
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.
- Open ModelDoc
- Add > Add Meshes
- Find your regular weapon mesh [PAIN POINT: Allow Drag + Drop meshes from explorer?]
- Click Compile
- Save your vmdl (we're saving as rust_shotgun.vmdl).
You should now have an un-materialed weapon model.
- Duplicate (or copy and paste) your .fbx in the list, for each LOD.
- Rename them and select the meshes for each LOD.
- Add > LOD Group.
- Duplicate the group, or do Add again, assign your meshes to the LODs properly.
- 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
- Add > Default Material Group
- Open Material Editor [PAIN POINT: Should Right click texture in asset browser > Create Material]
- File > New [PAIN POINT: Too Many Shaders]
- Save in your textures folder
- 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]
- Go back to ModelDoc, set the material in your DefaultMaterialGroup
Physics
- Add > Physics Shape Capsule
- Select Root Bone (or none if none)
- Place a few shapes to cover a decent amount of the weapon.
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.
Attachments
Create an attachment for the muzzle flash to come out of. Call it muzzle.
Create an attachment for the bullet casings to come out of. Call it ejection_point.
- If you don't already have one, create a bone called "root" and set it as the bone in your mesh's properties. Then, create an attached bone called "hold_R" (or, if using Citizen v1, "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]
Debiggerfying
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.
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.
- Set the hands material (search for rust_hands)
- Set Muzzle attachment (make sure the parent bone is on the barrel of the gun)
- Add > Simple Animations
- Select all the v_ animations
- Drag the idle animation to the top
Animgraph
- Copy and and paste the v_*.vanmgrph from another weapon
- Name it v_[weaponname].vanmgrph
- Click the magnifying glass next to Graph: and select it
- Click Edit next to Graph:
- Click the Cog opposite Preview on the top right (you might need to make the column wider)
- Select your v_ model here
- Fix the animations on the nodes with the old weapon's name (v_oldweapon@idle etc)
- Save and close
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.
- In ModelDoc, Add ModelModifier_Translate
- Change the model position offset while watching in game