Weapon Creation – Arma Reforger

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
 
(56 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{TOC|side}}
{{TOC|side}}
= Goals of this tutorial =
== Tutorial Goal ==
{{Messagebox|'''Overview'''
In this tutorial you will learn about:
In this tutorial you will learn about:


* Importing your first FBX file
* Importing your first FBX file
* Adding sockets & skeleton
* Adding sockets & skeleton
* How to configure new weapon
* How to configure new weapon|💬|#CDF}}{{Feature|informative|If you '''don't have any experience with Workbench''' yet, it is recommended to '''go through [[Arma Reforger:Weapon Modding|modded weapon tutorial]]''' to familiarise with some of the concepts present in the '''Workbench'''.}}
{{Messagebox|Sources files for this tutorial can be found at '''{{Link|https://github.com/BohemiaInteractive/Arma-Reforger-Samples/tree/main/SampleMod_NewWeapon|Arma Reforger Samples Github repository}}'''.|📥|orange}}


= Adding new weapon =
== Add New Weapon ==
'''Overview'''
{{Feature|informative|Preparation phase consist of things like:


Preparation phase consist of things like:
* '''Preparing basic structure'''
* '''Preparing mesh'''
* '''Exporting mesh'''
}}


* Preparing basic structure
* Preparing mesh
* Exporting mesh


=== Preparing structure ===
== Structure Preparation ==
While keeping to official structure is not mandatory and there are no engine restrictions asset wise about it, it's recommended to follow guidelines listed here - Data (file) structure - to ensure that all automation plugins are parsing your assets correctly and make it later easy to navigate.
 
While sticking to official structure is not mandatory and there are no engine restrictions asset wise about it, it is recommended to follow guidelines listed here - [[Arma_Reforger:Directory_Structure|Data (file) structure]] - to ensure that all automation plugins are parsing your assets correctly and make it later easy to navigate.


Therefore, your first task will be preparing following file structure
Therefore, your first task will be preparing following file structure
Line 23: Line 26:
[[Image:armareforger-new-weapon-file-structure.png|1200px]]
[[Image:armareforger-new-weapon-file-structure.png|1200px]]


=== Preparing mesh ===
Most of the  '''Weapon Pipeline'''  is documented quite so I highly recommend to read that page before going through next steps. This tutorial will try to cover any missing parts that you could encounter when plugging in new weapon. This tutorial is also more focused on Blender user but please don't worry - most of the things are working very similar in other 3D software packages.
==== Object orientation ====
One of the most important thing to begin with is making sure that your '''model is properly orientated.''' As per [[Arma_Reforger:FBX_Import#Alignment]] page:
{{Feature|informative|Everything must be oriented as pointing along/towards the Y+ axis in Blender and 3dsMax and along Z+ axis in Maya}}
That means, when you are '''importing A3 weapon you need to rotate it by 90 degrees to the left.'''
==== Cutting object to parts ====
Most likely model that you might already have few bits already present in the mesh. Since Enfusion allows you to assemble weapon from multiple parts, we will split our mesh into multiple separate objects to achieve much higher customization of weapon.
[[Image:armareforger-new-weapon-cutting-parts.gif|600px]]
In this case, sample contains two parts which could be potentially moved to separate files, letting you to have 3 variants in total quite easily. As marked on above video, grip & iron sights were moved to separate FBX files. Magazine was already separated for that particular mesh so only remaining thing to do is adding slot points for those accessories.
==== Naming of objects ====
When it comes to naming, there are few important rules to keep in mind.
# '''_LODx''' suffix is used to indicate '''Level of Details'''
# '''UBX_, UCX_, USP_, UCS_, UCL_, UTM_''' prefixes are used to mark '''Colliders'''
# '''OCC_''' prefix is used for '''Geometry Occluders'''
Beside that, there are also some additional guidelines regarding naming of the objects -  '''slot/snap points naming convention''' - itself which don't have effect on how mesh is processed by engine (like those mentioned above) but are there to '''have consistency'''. It's also worth to note that some of base weapon prefabs are using some of those names '''by default''' (they can be of course changed but it's strongly advised to follow those rules nevertheless). 
==== Adding slots/snap points ====
If you had experience with Arma 3 modding, then whole concept of having slots & snap points should be fairly familiar to you. Those dummy objects are serving as ''memory points -'' there is one major difference though - you no longer have to place two points to make an axis. Instead, rotation of dummy object is used.
In Blender, you can use one of the '''empty objects''' like '''Plain Axis''' to create those helper points.
[[Image:armareforger-new-weapon-empty-snap.jpg|300px|right]]
[[Image:armareforger-new-weapon-empty-create.png|300px]]
''Please notice Plain Axis gizmo - this is the orientation of the model. Make sure that your empty object is  '''properly aligned''''' 
[[Image:armareforger-new-weapon-empty-rotate.png|600px]]
{{Clear}}
{{Feature|informative|One easy method to have slot & snap points correctly aligned is to create first slot points, when the mesh is still in one piece, and then copy paste mesh & empty socket to new empty scene. After that only thing left is to rename  '''''slot_XX''''' to  '''''snap_XX''''' .}}
==== Colliders & material names ====
Colliders are special type of objects which are used to calculate various kinds of collisions - be it physic simulation or tracing of bullet penetration. There are few rules regarding those colliders and most of them listed here - FBX import#Colliderusage
When importing asset from previous Arma game - like in this example - you are most likely going to have already convex components ready from Geometry, Fire Geometry, View Geometry or Geometry Physx LODs.
If you are using Blender, there is small handy tool to assist you with assigning correct game materials & layer presets on colliders.
==== Setting skeleton & rigging mesh ====
When creating skinned objects, Enfusion Workbench expects that the whole object is skinned to some bone. Otherwise importer will try to "fix" it by skinning remaining faces to some root bone.
In Blender realms, this means that any object which Armature modifier, must be fully skinned to some existing bone through vertex groups.
If you have some animated collider please keep in mind that '''only trimesh colliders can be skinned'''. In all other cases you have to use '''100% weight'''.
In Blender it gets even bit more tricky and '''Object Relations''' (in '''''Object tab''''') have to be used.
[[Image:armareforger-new-weapon-relations.png|400px]]
=== FBX export settings ===
Most of the general rules can be found on this page  '''this page''' . In principle, when export from i.e. 3DS Max, you have to make sure that you are exporting in '''binary format in version 2014/2015.''' Furthermore, '''Triangulation''' & '''Preserve Edge Orientation should be turned off.'''
Blender wise, there are 3 most important things to keep in mind when exporting FBX
{| class="wikitable"
|
# '''Object Types''':
For animated object like weapon you need to have checked on at least:
'''Empty -''' which handles all snap points
'''Armature''' '''-''' exports skeleton of your weapon
'''Mesh -''' self explanatory
| rowspan="3" |[[Image:armareforger-new-weapon-export-blender2.png|200px]]
|-
|'''2. Custom Properties''':
Without this option all custom properties like '''LayerPresets''' would be lost!
|-
| colspan="1" |'''3. Leaf bones''':
Leaf bones are completely unnecessary in Enfusion and it's better to have that option '''turned off'''
|}
=== Preparing textures ===
When importing textures of weapon from previous Real Virtuality games like Arma 3 there is no real automated or simple method of conversion spec-gloss textures to PBR (''Physicial Based Rendering'') Metal Rough ones - current industry standard. Therefore in most cases it's much easier to do textures from scratch in i.e. Substance Painter.
There are tons of materials on the internet how to create proper PBR texture and if yo
----
== Importing Mesh ==
'''Overview'''
In this chapter following topics will be explained
* Importing new model
* Importing textures
=== Importing & registering new model ===
Once mesh was successfully prepared and all selections, sockets & snap points are in place, it's time to try our asset in game. Majority of the process is already pretty well described on FBX import - Import process in the Workbench page.
In principle, all you have to do is click with right mouse button on your FBX files and select from
[[Image:armareforger-new-weapon-mesh-register.gif|600px]]
==== Checking colliders & materials ====
After initial import was done it's time to make sure that materials & colliders are using proper materials & colliders. By default, Enfusion will try to assign material based on the name of the assigned texture in mesh. If it fails to find such texture, new dummy material (see area marked in orange on screen below) will be created next to the FBX model.
There are 2 typical errors when it comes to collider configuration:
[[File:armareforger-new-weapon-collider-errors.png|thumb|left|800px|Colliders errors example]]
{{Feature|important|Make sure that you have "usage" property defined in collider object properties.
[[Image:armareforger-fbx-layers-blender-1.png|200px]]
More info about it can be found on [[Arma_Reforger:FBX_Import]]}}
{{Feature|important|Make sure that correct material is assigned to all colliders
[[Image:armareforger-new-weapon-colliders-material.png|200px]]
More info about it can be found on [[Arma_Reforger:FBX_Import]]}}
{{Clear}}
==== Skeleton & hierarchy ====
Since this model is animated, it's very important to check '''Export Skinning''' & '''Export Scene Hierarchy''' check boxes. Without those two parameters selected, your weapon would be without either skinning or sockets/snap points!
[[Image:armareforger-new-weapon-import-settings.png|400px]]
=== Importing textures ===
In principle, you can use same procedures as the ones described on [[Arma_Reforger:Weapon_Modding#From_Scratch|Weapon Modding]] page
For purpose of this tutorial, create following three materials:
* '''SampleWeapon_01_Camo1.emat'''  material with two textures
** '''SampleWeapon_01_Camo1_BCR -''' Base color + Roughness
** '''SampleWeapon_01_Camo1_NMO -''' Normal map
* '''SampleWeapon_01_Camo2.emat'''  also with two textures
** '''SampleWeapon_01_Camo2_BCR -''' Base color + Roughness
** '''SampleWeapon_01_Camo2_NMO -''' Normal map
----
== Weapon configuration ==
'''Overview'''
In this chapter we will learn how fuel is simulated in game and we will change following things:
* Creating new rifle prefab
* Configuring basic weapon parameters
=== Basic weapon configuration ===
==== Basic weapon prefab setup ====
When making prefabs of weapons it's recommended to inherit from one of the already existing prefabs located in  '''''Prefabs\Weapons\Core -'''''  those prefabs should have most of the necessary configuration for various kinds of weapons.
In this case we will use [enfusion://ResourceManager/~ArmaReforger:Prefabs/Weapons/Core/Rifle_Base.et '''Rifle_Base.et'''] as parent prefab. To do so, navigate in  '''Resource Browser'''  attached to  '''World Editor'''  to  '''''Prefabs\Weapons\Core'''''  & locate [enfusion://ResourceManager/~ArmaReforger:Prefabs/Weapons/Core/Rifle_Base.et '''Rifle_Base.et'''] prefab. Once you are there, click with right mouse button on that prefab and select '''Inherit Prefab in Addon''' from context menu.
{{Feature|informative|Other method involves duplicating some already existing prefab - this might be handy if you are creating something similar to already existing weapons. For instance if you are making some new M16 variant, you could use '''Duplicate in "addon name"''' function on [enfusion://ResourceManager/~ArmaReforger:Prefabs/Weapons/Rifles/M16/Rifle_M16A2_base.et '''Rifle_M16A2_base.et'''] and then modify parameters of such new prefab.
.}}
After new prefab is created, it is possible to start modifying this prefab. First step would be assigning correct model - '''''SampleWeapon_01.xob''''' - to '''MeshObject''' component.
==== Changing inventory parameters ====
In '''SCR_WeaponAttachmentsStorageComponent''' it is possible to adjust some of the basic item properties related to inventory but there is also one section which is used for defining weapon IK pose (''RV veterans might find it similar to handAnims parameter).'' Animation IK pose is not going to be described in this paragraph though so let's move to inventory configuration.
When looking at '''SCR_WeaponAttachmentsStorageComponent''', multiple '''Attributes''' can be observed like:
* '''Item Display Name''' - as name suggest, here it is possible to change Name and Description (on-hover tool tip visible in in-game inventory)
* '''Item Phys Attributes''' - various physical attributes of the item like mass, volume, etc
* '''Item Animation Attributes''' - here are defined item IK poses defined
Beside those attributes, there are also '''Custom Attributes''' where it is possible to for example change '''Item Inspection Anim''' or character max speed when given item is equipped or change '''PreviewRenderAttributes''', which controls the little preview of weapon in inventory menu - if your weapon has some odd size, it might necessary to adjust camera parameters over there.
In '''Rifle_Base''' prefab, '''Item Phys Attributes''' is not configured and it is necessary to use '''"set class"''' button next to it. This action will enable this section and fill it with some default values, which can be freely changed afterwards..
For this '''Sample Weapon,''' following changes were done:
* In '''Item Display Name''' section, '''Name''' property was changed to name of the weapon - in this case it is just "Sample Weapon"
* '''In Item Phys Attributes''' :
** '''Weight''' parameter was adjusted to somehow match the weight of real weapon without any accessories (including magazine). This '''parameter is using''' '''kilograms''' and in this example it was set to 4kg
** '''Size Setup Strategy''' was setup to '''Volume.''' This means that size of that object will be calculated using '''Item Volume''' .
** '''Item Volume''' [in cm3] defines how much space in inventory takes that object. In this example it is set to '''3000''' just to showcase how it works, normally, 3000 is used for machine guns, while rifle like AK74 has this value set to '''1500'''
==== Configuring weapon characteristics ====
Most of the weapon firing characteristic can be changed in '''MuzzleComponent''' which is child of '''WeaponComponent'''. Over there, it is possible to '''Fire Modes, Dispersion, Bullet Init Speed Coef, Magazines''' and others. In this segment, focus would be but on getting '''fire modes''' set correctly.
Starting with '''Fire Modes''', '''Rifle_Base''' prefab has by default fire modes - '''Safe''' & '''Single''' fire mode, therefore it is assumed that any rifle has a safe mode. If it's not the case for the asset that you are preparing, then it might be necessary to create new base prefab based of '''Weapon_Base''' prefab - this scenario is not going to be described here though.
For purpose of this tutorial, '''Sample Weapon''' is equipped with three fire modes - safe, single & full auto. Since parent prefab has only two fire modes, a new one has to be added through + sign on the right side of the '''Fire Modes''' property. Once it's there, it can be filled with proper data.
'''BaseFireMode''' with '''Max''' '''Burst''' set to 1 will work as single fire mode'''.''' On newly added '''BaseFireMode, Max Burst''' should be set to -1 - this fire mode will work as full auto mode.
Burst fire weapons can be configured by setting '''Max Burst''' property to something above 1. In this case, new property will appear - '''Burst Type'''. Over there it is possible to select 3 types of burst fire:
* '''Uninterruptible''' - once player presses fire button, weapon will fire exactly the amount of shots defined in '''Max Burst''' (unless weapon runs out of ammo)
* '''Interruptible''' - burst fire will be interrupted once player release fire button. Burst memory is present ( https://en.wikipedia.org/wiki/Burst_mode_(weapons) )
* '''InterruptibleAndReseting''' - same as above but without burst memory
==== Configuring recoil ====
Weapon '''recoil''' is in configured on of the sub classes of '''Weapon Aim Modifiers. Rifle_Base''' prefab is missing '''RecoilWeaponAimModifier & ZeroingWeaponAimModifier''' subclasses in '''Weapon Aim Modifiers''', therefore those have to be added to it. After those classes are added, it will be necessary to tweak the recoil manually. As reference, either screen below or AK74 prefab can be used as reference.
==== Setting zeroing adjustments ====
First, you need to setup '''SightsComponent''' and fill in '''Sights Ranges''' with desired zeroings of your weapon.
'''X''' value represents '''animation source value''' & '''Y''' represents '''desired zeroing range in meters''' (note that this value is also shared by UI). In example above, there are only zeroings available with 300 & 500 meters range. Once you have filled that data you can click with right mouse button on '''WeaponComponent''' & then select from context menu "'''Process zeroing data'''". This button will automatically calculate necessary offsets for weapon positions so, comparing to i.e. Arma 3 animated iron sights, you don't have to manually create those eye points for each range.
==== Basic magazine prefab setup ====
New magazine prefab can be easily created by inheriting from [enfusion://ResourceManager/~ArmaReforger:Prefabs/Weapons/Core/Magazine_Base.et '''Magazine_Base.et'''] prefab. Once new prefab inheriting from [enfusion://ResourceManager/~ArmaReforger:Prefabs/Weapons/Core/Magazine_Base.et '''Magazine_Base.et'''] is prepared, it is possible to assign magazine model in '''MeshObject.'''
Next step will be modification of magazine related properties in '''MagazineComponent'''. Over there, it s possible to set 
In '''InventoryItemComponent,''' similar to main weapon, it is possible to change inventory related properties like name or weight. In this example, values were set as on picture below.
==== Creating new Magazine Well ====
Magazine wells are classes, which help to establish multi weapon (& mods) magazine compatibility. Any magazine which is using selected class will be usable in any other weapon, which is using exactly same magazine well.
In Arma Reforger, there are already '''plenty of magazine wells available''' but since this sample weapon is using rather unique magazine well, a new one has to be created.
New '''magazine well''' can be added to the list by creating a '''new script file''' in one of the '''game script folders''' (f.e. ''Scripts/Game/Weapon'' folder can be used - if you don't have such folder, then you would to create them manually). There are no requirements to the name of the script file but it is suggested to use '''MagazineWell_''' prefix to make things clear. Once script is created, the only remaining thing is to create a new class which inherits from '''BaseMagazineWell'''. <syntaxhighlight lang="c#" line="1">
// Script File
class MagazineWell65x39C_SampleWeaponClass {}
MagazineWell65x39C_SampleWeaponClass MagazineWell65x39C_SampleWeaponSource;
class MagazineWell65x39C_SampleWeapon : BaseMagazineWell
{
}
</syntaxhighlight>In example above, new magazine well is called '''MagazineWell65x39C_SampleWeapon.'''
After magazine well is created, it will be necessary to recompile all game scripts via either '''Compile and Reload Scripts''' (Shift+F7) option in '''Script Editor''' or '''Reload Game Scripts''' (Ctrl+R) in '''World Editor'''. Once scripts are compiled it should be possible to assign that class in '''Magazine Well''' property found both in '''MagazineComponent''' of magazine and '''MuzzleComponent''' of weapon.
==== Adding weapon & magazines to crates ====
Once weapon and magazine are ready, it is possible to add those to crates, so they can be picked up either in Conflict armory or during Game Master sessions. In principle, there are two types of crates available in game:
* '''Arsenal crates''' - those can be either unlimited or be single use. Closely tied to '''playable Factions.''' It is impossible to precisely specify amount of available items.
* '''Regular storage crates''' - using standard storage system, where creator defines exact amount of items, which are available inside of the crate.
===== Arsenal crates =====
Adding new items to existing '''Faction Arsenals''' crates involves following steps:
* Creating override of '''existing Arsenal config''' - either '''ArsenalConfig_BLUFOR.conf''' (''used by US Army''), '''ArsenalConfig_INDFOR.conf''' (''used by FIA'') or '''ArsenalConfig_OPFOR.conf''' (''used by USSR faction'') - by using '''Override in "addon name"''' functionality
* Open overridden file and adding of new entry to '''Arsenal Items''' array by clicking on plus icon
* '''Assigning prefab of item''', which is supposed to be visible in Arsenal crate, to '''Item Resource Name''' property. This can be done either by clicking on button with two dots or by dragging and dropping prefab on this field
* Selecting proper '''Item Type & Item Mode''' from the drop down menu.
** For rifles, '''Item Type''' can be set to '''RIFLE''' and '''Item Mode''' to '''WEAPON'''
** For rifle magazines, '''Item Type''' can be set to '''RIFLE''' and '''Item Mode''' to '''AMMUNITION'''
{{Feature|important|In 0.9.5.51 version of the game there is a bug, where default values of the new items are incorrect. Even if '''Item Type''' is by default selected to desired type of '''RIFLE''', it might be still necessary to select it again till the '''text in this field is bold.'''}}
Once those changes are performed, it might be necessary to '''Reload Game Scripts''' or even restart the Workbench. After that, those new items should be visible in existing crates in both '''Game Master''' and '''Conflict''' game mode.
===== Regular storage crates =====
If it is desired to have some specific amount of items, then it is possible to utilize '''UniversalInventoryStorageComponent''' (''or its SCR_ equivalent'') which can be added to basically to any entity with physics enabled.
{{Feature|informative|Process of adding such custom create to in-game editor is not covered here and this subject is pretty well covered on [Arma_Reforger:Asset_Browser_Mod_Integration '''Asset Browser Mod Integration'''] page.}}
First step, would be locating prefab where new item should be stored. In this tutorial '''AmmoBox_545x39_2160rnd.et''' was duplicated to addon as '''AmmoBox_SampleWeaponMagazines.et''' and then used as an example on how to add new magazines to it. Once that duplicated prefab is present in target addon, following things have to be done:


* Navigate to '''SCR_UniversalInventoryStorageComponent'''
== Creation Steps ==
* Add new entry to '''Multi Slots''' array
* Set '''Slot Template''' to '''InventoryStorageSlot''' and assign to it some unique name, i.e. ''Magazines''
* Assign magazine prefab to '''Prefab slot''' in this newly created '''Slot Template'''
* Change '''number of items''' present in this slot by modifying '''Num Slots''' value ''(f.e. it can be set to 25)''


After that, this crate should have 25 magazines of your choice inside
* {{Link|Arma Reforger:Weapon Creation/Asset Preparation}}
* {{Link|Arma Reforger:Weapon Creation/Prefab Configuration}}


{{Wiki|TODO}}
Then you may want to see:
* {{Link|Arma Reforger:Weapon Animation}}




{{GameCategory|armaR|Modding|Tutorials|Assets}}
{{GameCategory|armaR|Modding|Tutorials|Assets}}

Latest revision as of 09:43, 5 December 2024

Tutorial Goal

💬
Overview

In this tutorial you will learn about:

  • Importing your first FBX file
  • Adding sockets & skeleton
  • How to configure new weapon
If you don't have any experience with Workbench yet, it is recommended to go through modded weapon tutorial to familiarise with some of the concepts present in the Workbench.
📥
Sources files for this tutorial can be found at Arma Reforger Samples Github repository.

Add New Weapon

Preparation phase consist of things like:
  • Preparing basic structure
  • Preparing mesh
  • Exporting mesh


Structure Preparation

While sticking to official structure is not mandatory and there are no engine restrictions asset wise about it, it is recommended to follow guidelines listed here - Data (file) structure - to ensure that all automation plugins are parsing your assets correctly and make it later easy to navigate.

Therefore, your first task will be preparing following file structure

armareforger-new-weapon-file-structure.png


Creation Steps

Then you may want to see: