Weapons

Overview

This section contains topics that include information on weapon modeling and instructions for setting up first- and third-person weapons for various DCC tools taking into account a step-by-step process of what is required to see your weapon working in-game. This particular example will be explaining how to setup a first person weapon because of the complexity involved with animations. Third person weapons are essentially just the static object versions which the player can pick up and drop.

Preparation

Before going any further you should have your weapon exported, rigged and textured. That means there should be at least one .chr file with a corresponding .mtl associated its textures. Generally speaking, weapons will be located in Objects/weapons so for the sake of consistency it is recommended you put your textures, materials and geometry in there. As an example, the SDK rifle can be found there as well. Animations will also be an important factor but they will need to be exported after you have created a chrparams file.

\Objects\weapons\rifle
  • Assuming that a traditional gun is being used (in this case a rifle) you will need to create several animations related to reloading and recoil. Your setup may vary but keep this in mind when planning your assets on what you need.
  • With that in mind you will also need several joints to animate, if you are basing our example of the rifle you will need about six joints. The ones used for the rifle are listed below but keep in mind that naming for weapons is not hard-coded.

The .chrparams File

This file is basically mapping animations to model files. In this instance you only need it to assign a basic relationship between these two assets. For more information on this file and what you can do with it not mentioned in this tutorial please visit Character Parameters File (chrparams).

  1. Create a text file called whatever the name of your main weapon asset is followed by .chrparams like this:


  2. The .chrparams file can have a basic entry to look for animations in batch like this:
<Params>
 <AnimationList>
 <Animation name="#filepath" path="Animations\weapons\rifle\"/>
 <Animation name="$TracksDatabase" path="Animations\weapons\rifle\rifle.dba"/> 
 <Animation name="" path=".caf"/>
 </AnimationList>
 </Params>

Getting Animations Playing

Now you can export your animations in whichever DCC tool you are using. Be sure that you export to the same path you referenced in your .chrparams. Doing so should output single or multiple (depending on how many you want to use on your animation) .i_caf files.

  1. i_caf is your uncompressed, raw animation file from here you can then open the Animation Import tool found in Sandbox. This windows two primary uses for this example will be adding your "skeleton" to the skeleton list and then generating a .animsettings file.
  2. Add your .chr to the skeleton list by clicking "Add..." and selecting your file from there.
  3. Select all of your animations on the left hand side and then doubly click on your newly added chr to the right side. This will add the "skeleton" to the Animation Settings to ensure proper association. From there, click "Save All"


  4. From there you should now be able to preview your animations playing with your weapon. You may need to restart the editor to make sure all the scripts are updated but from here you should be able to go into the Character Editor, select the .chr file and see the animations as a list and playable:



  5. If you can see this then you are on the right track and ready to move to the next step. Note that for the rifle it is mostly just moving bones. We created a .cdf file which has things like the clip attached to the bones via Bone Attachment. This is not necessary but it is an easy way to manage visibility.

Adding Special Parts

You will not be able to preview everything right away but at this part you will be able to create additional attachments to spawn particle effects or just more parts around.

  1. You should still be in the Character Editor at this point, if you aren't open it up and load your .chr file.
  2. Click "New" in the lower left hand and name it whatever you like. In this case we are adding a rifle magazine so name it something relevant. Then click the "..." next to the Object path (while the attachment is selected) and add a .cgf of your choice. If you do not have your own you can choose the one defined in the image below. Once you have done so, be sure to click "Bone Attachment" then define the most relative bone to this which has been animated. The Rifle example has a bone labeled 04-magazine2 so this one was chosen. When you preview your reload animation now the clip should now follow the defined bone. You may need to click "Align with Bone" to get your magazine to properly align, after you have done so be sure to click Apply.
  3. Save the .cdf by going to File-Save As.

The Weapon Script

Next we will go into the weapons xml scripts. These files are what defines the properties in how the weapon will work. You can find the rifle.xml here:

\Game\Scripts\Scripts\Entities\Items\XML\Weapons
  • Much of the parameters in this file are commented in the file itself so the contents of this file will not be explained in this tutorial. What should be noted is this file is what adds the weapon as an option in the entities so with the physical xml file you will also need to define a unique name :
<item name="Rifle" class="Weapon" category="primary" priority="12" weaponParams="1">
  • So if you want (depending on your type of weapon being used) you can use the SDK weapon scripts as your base starting point.
  • You can also find that this is where the parameters for ammo types as well as attachments for weapons are stored.
  • For more information on what each parameter means in the weapon xml please visit Weapon Scripts.

Wrapping Up

Once your script has been made you should be able to add your new weapon in Sandbox. If you are unfamiliar with where to find where the weapons are located within the RolupBar here:

  • From there drag your weapon into the editor, jump in game and then press F to pick it up!

  • From here you will likely need some refinement to get your desired look whether its modifying particle effects, adding more animations, fire modes, ammo types. Really its up to you how the weapon looks and works.

If you are just modifying the script of the weapon you can just click "Reload Script" for it to update. From there the weapon should update the next time you go in-game to test it out.