1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

HOWTO: New Unit Creation

Discussion in 'Civ5 - Modding Tutorials & Reference' started by lemmy101, Oct 20, 2010.

  1. lemmy101

    lemmy101 Chieftain

    Joined:
    Apr 10, 2006
    Messages:
    1,064
    How to Add New Units in Mods The EASY WAY!

    Tool by Lemmy101 and CaptainBinky



    DRAGON IMAGE COURTESY OF DELIVERATOR

    This tutorial explains how to get completely new unit models into the game THE EASY WAY. This will be a completely new unit from an FBX with an animation, with stats equivalent to a warrior without you having to write or edit a single line of XML.

    For a more in-depth manual guide that was written before Nexus Buddy and so involved xml editing, click here. It's probably worth reading so you know what Nexus Buddy is doing in the background.

    What You'll Need

    You will need ALL of these before you can start:

    Nexus configured and running properly (bugs aside)
    IndieStone Nexus Buddy
    FPK files unpacked: Load the Nexus Art Tool, select the "Nexus" tab, click "Script Browser", select "Extract PAK (*.fpk) files", click "Run Script", and... wait.


    Nexus Buddy

    1. Export an FBX (using FBX 2010 exporter in Max, or Blender 2.49b FBX exporter or equivelent) with an animation. The model should use 32 bones or less to work properly though in some cases more will work.

    2. Place the FBX in a directory along with DDS versions of any textures used on it. In my example I'll be using a Captain.FBX and Captain_Body_diff.dds. They are placed in C:\Captain\



    The texture is named after the mesh it will be put onto, so since in 3DSMax the Captain mesh was called 'Captain_Body' I named the texture 'Captain_Body_diff.dds' so it will automatically be placed on that mesh ('diff' meaning 'diffuse' which is what the main colour texture is called) if you don't know the name of your mesh, you can set the texture manually so don't worry.

    3. Place Nexus Buddy into your Nexus folder. In my case it's "c:\Program Files(x86)\Steam\SteamApps\Common\Sid Meier's Civilization V SDK\Nexus\x86\".

    4. Run Nexus Buddy and select 'Create a unit' from the main menu. Then select your 'FBX' file in the open file dialog box.

    This will import your Captain.FBX into the program. Next time you save or export, it will create a Captain.gr2 in the same folder containing all the material changes you make in here. You will also get a Captain.isxml file which is your Nexus Buddy project file and can be used to reload your entire unit project at a later time.



    Things to notice. Firstly, we have one mesh called 'Captain_Body'. (Yours will differ.)

    Secondly, you have at least one material that Nexus Buddy has created, one per mesh in your model, and those materials are assigned to the relevant meshes (just the one in my case). It will automatically have assigned the texture to the correct material/mesh due to the naming we used. If not, you can click the material in the list box, and select it's texture in the BaseTextureMap property on the right.




    5. Assuming our textures are now assigned to materials properly, click the Unit FXSXML tab at the top to get onto the next page:



    6. Click on the 'add' button to add a new animation for our unit that will use the full length of the source fbx animation. In my case 20 frames.



    It will name it by default to 'NewAnimation1', you can change this to something relevant in the properties to the right. In my case I called it 'Run', which is what the anim in the source fbx was. We can edit the Start and End frames here later as we add more animations to the main fbx.

    7. If you wish, you can edit a bunch of the unit's stats and stuff on the 'Unit Details' tab, but it's created defaults, so we'll just use them and can come back here later to tweak.



    8. Now we're going to create a mod for our unit! Load up Mod Buddy.

    9. Click 'New Mod'



    10. Name it. I called mine 'CaptainMod'. Click OK then fill in all the mod details (description, author etc) and click 'Finish'

    11. Alt tab back into Nexus Buddy and select the 'Mod Buddy Export' tab. Select the mod project file in the 'Target Mod' property, then click 'export to mod buddy'.




    12. Alt tab back to Mod Buddy, and click 'Reload' on the dialog that's popped up. And that's it! you should see your project there all ready to go! Nexus Buddy has added all the files you need to the project. Wee!



    AND THAT'S IT!

    Click Build->Build Solution from your main menu, then load Civ 5! Select the mod from the mod browser, and start a game:




    YAAAAAAAAY!

    Let's build one...



    GO GO CAPTAIN!

    From Here

    Of course the work is not finished yet. For one, he is constantly playing just one animation. Two, you probably want to tweak all his stats and such. Some of this can be done from within Nexus Buddy. Just explore the 'Unit Details' tab:

    You can edit these and re-export, then Build->Build Solution again to fine tune your unit's stats.

    Some more advanced editing will require editing the XML, but this has saved you a whole bunch of time and leaves you to the more fun task of designing the unit's actual gameplay stats.

    Also, obviously you don't want him to be constantly running, or idling or whatever the anim you exported in the FBX was.

    Adding a new animation

    So you need to get making other animations. Then you can tie these animations to different actions. How? Well first you would reimport the FBX with the 'reimport fbx' button on the Granny File page.

    Now let's suppose you have another anim in your imported FBX and you wish to use it.

    So at the moment my Run anim is using all 20 of the frames.



    Supposing I've reimported a new FBX with two 10 frame animations. So I want to click on my run anim and set the end frame to be 10. in the properties to the right:



    Then I click on 'add' to add another animation, we'll assume this is an 'Idle', and set the start frame to 11 and the end to 20:



    Note I could click 'add external' to add an external animation.gr2 file from a different export too. Supposing I was converting a Civ 4 unit, I could export all the anims seperately in different FBX files, then once I've exported them all with Nexus Buddy, make a new unit at the end just adding all the anims I exported in the first bunch of times, instead of bothering with frame numbers and so on.

    Assigning the animation to actions.

    Lastly, we now want to make sure the newly added animation get used by the unit.

    Take a look at the 'Event Code Bindings' section of this page:



    In the first column it shows every action a unit can do (a combat land unit, which is what template we have selected, and the only one that exists in the version of Nexus Buddy at time of writing)

    In the second column is what anim it will play when it performs that action. You can see they have all defaulted to use your first animation.



    Simply click one of the actions, and a drop down will appear. Use this to change your different actions to perform different animations.

    Re-export to Mod Buddy when you're done!

    That's all there is to it! Enjoy your new units!

    Hurray!
     
  2. lemmy101

    lemmy101 Chieftain

    Joined:
    Apr 10, 2006
    Messages:
    1,064
    How to Add New Units in Mods THE HARD WAY!



    DRAGON IMAGE COURTESY OF DELIVERATOR

    This thread explains how to get completely new unit models into the game. We will replace the warrior with a completely new model using its own animations, textures and skeleton.

    This tutorial won't cover creating a new seperate additional unit that can be built alongside the warrior, with its own tech prereq and stats, but from here you should be able to figure this out. If not I'm sure there will be other tutorials around to help you after this tutorial, but if not we will look into making one at some point.

    What You'll Need

    Nexus configured and running properly (bugs aside)
    IndieStone Material Maker
    IndieStone Nexus animation bug fix
    FPK files unpacked: Load the Nexus Art Tool, select the "Nexus" tab, click "Script Browser", select "Extract PAK (*.fpk) files", click "Run Script", and... wait.

    Part 1 - Creating the game assets

    1. Apply the Nexus animation bug fix.

    2. Export an FBX (using FBX 2010 exporter in Max, or Blender 2.49b FBX exporter or equivelent) with an animation. The model must use 32 bones or less to work properly.

    3. Load Nexus, and click Asset Import

    4. Click Choose Import Source and select your FBX.

    5. Click Next

    6. Click Animation Manager to open up the... animation manager.

    7. Click 'Add'



    This will create an animation spreading over the entire exported animation time. Ultimately you will need to create all your anims in here, with start frame / end frame and names, but for now we'll assume you're just using one anim.

    8. Name your animation



    9. Close the material manager and click 'Next'. You may want to check make sure your model looks right in the 3D preview. Note that it should appear in a solid bright pink colour, but make sure the actual model geometry looks right.

    10. Select the output directory. Don't put it directly into Civ 5's 'Common' directory or otherwise later on you'll overwrite your fixed files!!! Put it in your work directory wherever it is. I'll assume you put it in C:\Captain\

    11. Click Next

    12. Close Nexus entirely now, we don't need it any more!

    13. Browse to your output directory, you should see several files. An fxsxml file, which is an xml file containing references to all the files relating to your unit, as well as a gr2 file containing the actual model called in my case Captain.gr2. Then an animation gr2 file, in my case called CaptainRun0000.gr2. If you have an exporter.temp.gr2 just ignore that, it's just a temp file. In fact delete it!

    14. Open your .fxsxml file. In my case I have the following:

    Code:
    <Asset>
      <Mesh file="Captain.gr2" source="Tool" />
      <Animation file="CaptainRun_CaptainRun0000.gr2" name="CaptainRun0000" ec="1000" source="Tool" />
    </Asset>
    Note there is a bug which means it's inserting CaptainRun_ to the start of the path, which is incorrect. Edit it by removing the CaptainRun_ from the start (in your case it will say something different, but just make sure the file="" in the animation bit matches the filename of your animation)

    Code:
    <Asset>
      <Mesh file="Captain.gr2" source="Tool" />
      <Animation file="CaptainRun0000.gr2" name="CaptainRun0000" ec="1000" source="Tool" />
    </Asset>
    15. Next, we need to make this one animation the one that's used for EVERY possible action the unit can do in game, we do this by adding additional numbers to the 'ec' field:

    Code:
    <Asset>
      <Mesh file="Captain.gr2" source="Tool" />
      <Animation file="CaptainRun0000.gr2" name="CaptainRun0000" ec="1000, 1020, 1040, 1100, 1120, 1140, 1160, 1180, 1200, 1220, 1280, 1285, 1290, 1400, 1440, 1450, 1500, 1520, 1540, 1560, 1580, 1600, 1620, 1640, 1800, 2000, 2020, 2040, 2100, 2200, 2220, 2440" source="Tool" />
    </Asset>
    Each of these numbers refers to a different 'action', here is a complete list of the rifleman's actions:

    1000 - IdleA
    1020 - IdleA_Trans_IdleB
    1040 - FidgetA
    1100 - AttackA
    1120 - Charge_Run
    1140 - Charge_Attack
    1160 - AttackCityA
    1180 - AttackCityB
    1200 - DeathA
    1220 - DeathA_Idle
    1280 - Bombard_Defence
    1285 - Bombard_Defence_Idle
    1290 - Bombard_Defence_Idle_Trans_IdleA
    1400 - Run
    1440 - Stop_Run
    1450 - Shuffle
    1500 - Fortify
    1520 - Fortify_Idle
    1540 - Fortify_Idle_Fidget
    1560 - Fortify_Idle_Trans_Combat_Ready_Idle
    1580 - Fortify_Idle_Trans_IdleA
    1600 - Combat_Ready
    1620 - Combat_Ready_Idle
    1640 - Combat_Ready_Idle_Trans_IdleA
    1800 - Victory
    2000 - IdleB
    2020 - IdleB_Trans_IdleA
    2040 - FidgetB
    2100 - AttackB
    2200 - DeathB
    2220 - DeathB_Idle
    2440 - Stop_RunB

    This is not really important for this tutorial, but afterward this is the list you will consult to make new animations for the unit.

    16. Next, we want to add a bunch of files that control how the unit behaves. Most unit types in the game share these with eachother, so we'll just copy the ones out of the rifleman:
    Code:
    	<AnimGraph file="RUN_CHARGE_SHUFFLE_TO_SHUFFLE_RUN_CHARGE.dge"/>
    	<AnimGraph file="IDLE_OFFSET_CONTINUE_TRUE_GRAPH.dge"/>
    	<AnimGraph file="FORTIFY_FIDGET_GRAPH.dge"/>
    	<AnimGraph file="ENTER_FORTIFY.dge"/>
    	<AnimGraph file="LEAVE_BOMBARD_DEFEND_TRANS_IDLE_A_GRAPH.dge"/>
    	<AnimGraph file="DEATH_FINAL_GRAPH.dge"/>
    	<AnimGraph file="BOMBARD_DEFEND_LOOP_GRAPH.dge"/>
    	<AnimGraph file="ENTER_BOMBARD_DEFEND_GRAPH.dge"/>
    	<AnimGraph file="DEATH_GRAPH.dge"/>
    	<AnimGraph file="LEAVE_COMBAT_READY.dge"/>
    	<AnimGraph file="ENTER_COMBAT_READY_GRAPH.dge"/>
    	<AnimGraph file="FORTIFY_LEAVE_GRAPH.dge"/>
    	<AnimGraph file="COMBAT_READY_GRAPH.dge"/>
    	<AnimGraph file="FORTIFY_GRAPH.dge"/>
    	<AnimGraph file="TRANSITIONS_FOR_IDLES.dge"/>
    	<AnimGraph file="STOP_RUNNING.dge"/>
    	<AnimGraph file="IDLE_GRAPH.dge"/>
    	<AnimGraph file="FIDGETS_GRAPH.dge"/>
    	<AnimGraph file="MELEE_ATTACKS.dge"/>
    	<StateMachine file="1_OMNI_STATE_01.fsmxml"/>
    	<AnimGraph file="RUN_CHARGE_SHUFFLE_LOOP.dge"/>
    	<AnimGraph file="ATTACK_TO_RUN_CHARGE_SHUFFLE.dge"/>
    	<AnimGraph file="ATTACK_CITY_TO_RUN_CHARGE_SHUFFLE.dge"/>
    	<AnimGraph file="START_RUN_CHARGE_SHUFFLE.dge"/>
    	<AnimGraph file="SHUFFLE_STOP_GRAPH.dge"/>
    Our complete file now looks like this:

    Code:
    <Asset>
      <Mesh file="Captain.gr2" source="Tool" />
      <Animation file="CaptainRun0000.gr2" name="CaptainRun0000" ec="1000, 1020, 1040, 1100, 1120, 1140, 1160, 1180, 1200, 1220, 1280, 1285, 1290, 1400, 1440, 1450, 1500, 1520, 1540, 1560, 1580, 1600, 1620, 1640, 1800, 2000, 2020, 2040, 2100, 2200, 2220, 2440" source="Tool" />
    	<AnimGraph file="RUN_CHARGE_SHUFFLE_TO_SHUFFLE_RUN_CHARGE.dge"/>
    	<AnimGraph file="IDLE_OFFSET_CONTINUE_TRUE_GRAPH.dge"/>
    	<AnimGraph file="FORTIFY_FIDGET_GRAPH.dge"/>
    	<AnimGraph file="ENTER_FORTIFY.dge"/>
    	<AnimGraph file="LEAVE_BOMBARD_DEFEND_TRANS_IDLE_A_GRAPH.dge"/>
    	<AnimGraph file="DEATH_FINAL_GRAPH.dge"/>
    	<AnimGraph file="BOMBARD_DEFEND_LOOP_GRAPH.dge"/>
    	<AnimGraph file="ENTER_BOMBARD_DEFEND_GRAPH.dge"/>
    	<AnimGraph file="DEATH_GRAPH.dge"/>
    	<AnimGraph file="LEAVE_COMBAT_READY.dge"/>
    	<AnimGraph file="ENTER_COMBAT_READY_GRAPH.dge"/>
    	<AnimGraph file="FORTIFY_LEAVE_GRAPH.dge"/>
    	<AnimGraph file="COMBAT_READY_GRAPH.dge"/>
    	<AnimGraph file="FORTIFY_GRAPH.dge"/>
    	<AnimGraph file="TRANSITIONS_FOR_IDLES.dge"/>
    	<AnimGraph file="STOP_RUNNING.dge"/>
    	<AnimGraph file="IDLE_GRAPH.dge"/>
    	<AnimGraph file="FIDGETS_GRAPH.dge"/>
    	<AnimGraph file="MELEE_ATTACKS.dge"/>
    	<StateMachine file="1_OMNI_STATE_01.fsmxml"/>
    	<AnimGraph file="RUN_CHARGE_SHUFFLE_LOOP.dge"/>
    	<AnimGraph file="ATTACK_TO_RUN_CHARGE_SHUFFLE.dge"/>
    	<AnimGraph file="ATTACK_CITY_TO_RUN_CHARGE_SHUFFLE.dge"/>
    	<AnimGraph file="START_RUN_CHARGE_SHUFFLE.dge"/>
    	<AnimGraph file="SHUFFLE_STOP_GRAPH.dge"/>
    </Asset>
    16. Finally, we want to find the fx_triggers_rifleman.ftsxml in our Common folder, and make a copy of it into your c:\Captain\ work directory. Rename it. I called mine fx_triggers_captain.ftsxml.

    17. Then we add this line to the fxsxml:

    Code:
    <TimedTrigger file="FX_Triggers_Captain.ftsxml"/>
    Substituting it with your own filename, obviously.

    Now we're done with the fxsxml file, so save it and close it.

    18. Now we need to fix the texture on our unit. Download the Material Maker tool and place it in your Civilization V SDK/Nexus/x86 directory. Then run it.



    19. Load your main model gr2 file (Captain.gr2 in my case)

    20. Click 'add' to add a new material



    21. Select UnitShader_Skinned from the popup menu.

    22. Name your material with the Name property, and then use the BaseTextureMap to select your texture (the texture needs to be in dds format, I'll find links to an exporter after finishing the tutorial)





    23. Next click on <unassigned> next to your mesh to change it to point to your new material:



    24. Save and close the Material Maker.

    Congratulations! You have now got a fully working model (albeit with only one anim) ready to put into the game!

    Part 2 - Making the mod

    Thanks to Deliverator, who's tutorial I've kind of pilfered bits of. ;)

    1. Load up Mod Buddy

    2. Click 'New Mod'



    3. Name it. I called mine 'CaptainMod'. Fill in all the details and click 'Finish'

    4. Right click 'CaptainMod' in the 'Solution Explorer' select Add -> New Folder



    5. Call it 'Art'

    6. Drag all the files from your C:\Captain\ directory into the new Art folder (except your FBX if that's in there) You should have these in there now:



    Note the texture dds file is in there too. This is an updated screenshot since I forgot to put it in there last time. Silly me. In future screenshots it will be missing, but pretend it's not. Thanks ;)

    7. Next, find the civ5artdefines_unitmembers.xml file in the Civ 5/Resources/Common folder and drag that into your project (NOT in the Art folder but onto the CaptainMod)



    8. Double click the civ5artdefines_unitmembers.xml in your project to open it. This will open the xml file for editing:



    9. Find and edit the entries for the three different warrior art defines to point to Captain.fxsxml like this:

    Code:
     <UnitMemberArtInfo>
        <Type>ART_DEF_UNIT_MEMBER_WARRIOR</Type>
        <fScale>0.14</fScale>
        [COLOR="Red"]<Granny>Captain.fxsxml</Granny>[/COLOR]
        <Combat>
          <Defaults>ART_DEF_TEMPLATE_SOLDIER</Defaults>
          <bHasShortRangedAttack>1</bHasShortRangedAttack>
          <bReformBeforeCombat>1</bReformBeforeCombat>
          <Weapon>
            <WeaponTypeTag>BULLET</WeaponTypeTag>
            <WeaponTypeSoundOverrideTag>BULLET</WeaponTypeSoundOverrideTag>
          </Weapon>
        </Combat>
        <MaterialTypeTag>CLOTH</MaterialTypeTag>
        <MaterialTypeSoundOverrideTag>FLESH</MaterialTypeSoundOverrideTag>
      </UnitMemberArtInfo>
    Remember there are three of these to change, ART_DEF_UNIT_MEMBER_WARRIOR, ART_DEF_UNIT_MEMBER_WARRIOR_V2 and ART_DEF_UNIT_MEMBER_WARRIOR_V4

    10. Finally, right click CaptainMod in your Solution Explorer and click Properties



    11. In here click 'Reload Unit System'



    12. Save your Project and then run Build -> Build Solution from the main menu.

    AND THAT'S IT!

    Run the game, and activate your mod from the mod menu, and pick a Civ (don't be like me and pick Aztecs just to realise they have a unique unit instead of the one we replaced ;)) and when the game loads you should see your new units!



    From Here

    First of all, if you wish to add them as a completely new unit that can be built separately to the warrior, then a bit more XML work would be required. I will look into a tutorial for that later, but the principal would be finding all occurrences of warriors in the xml files and duplicating them, and making the duplicates point at the new fxsxml file.

    Secondly, of course you need to add new animations, when you do, simply load Nexus and redo the first part of the process, adding the new anims and start / end frames, and export. Note you don't need to update the Captain.gr2 file in ModBuddy, since this is just the mesh (unless you edited the mesh in the meantime, of course) but simply have to add the new gr2 anim files to the project, then add the new animation info into the fxsxml file, e.g:

    Code:
      <Mesh file="Captain.gr2" source="Tool" />
      <Animation file="CaptainRun0000.gr2" name="CaptainRun0000" ec="1000, 1020, 1040, 1100, 1120, 1140, 1160, 1180, 1200, 1220, 1280, 1285, 1290, 1400, 1440, 1450, 1500, 1520, 1540, 1560, 1580, 1600, 1620, 1640, 1800, 2000, 2020, 2040, 2100, 2200, 2220, 2440" source="Tool" />
      <Animation file="CaptainIdle0000.gr2" name="CaptainIdle0000" ec="">
    ... rest chopped out
    
    And finally, transfer the event codes (using the reference list) for which 'actions' you want him to use that animation for. Remembering to remove them from the first animation, they all should only appear once

    Code:
      <Mesh file="Captain.gr2" source="Tool" />
      <Animation file="CaptainRun0000.gr2" name="CaptainRun0000" ec="1020, 1040, 1100, 1120, 1140, 1160, 1180, 1200, 1220, 1280, 1285, 1290, 1400, 1440, 1450, 1500, 1520, 1540, 1560, 1580, 1600, 1620, 1640, 1800, 2020, 2040, 2100, 2200, 2220, 2440" source="Tool" />
      <Animation file="CaptainIdle0000.gr2" name="CaptainIdle0000" ec="1000,2000 ">
    ... rest chopped out
    
    Above I've removed 1000 and 2000 (IdleA and IdleB) from the Run anim and put it into the Idle anim.

    And once you've got all your anims in like this, then your new unit should animate properly! Hurray!

    Tool and export process by lemmy101 & CaptainBinky - Thanks to wirapuru, Deliverator and Ekmek
     
  3. poncratias

    poncratias Chieftain

    Joined:
    Feb 9, 2010
    Messages:
    336
    You know what a big jump you did for all of us, do you? ;)

    thx a LOT!!!
     
  4. Ekmek

    Ekmek on steam: ekmek_e

    Joined:
    Aug 7, 2002
    Messages:
    6,045
    Location:
    San Diego, California
    awesome Lemmy.

    Some notes I recal from seeing an older build of nexus:

    the state graph has nodes and a blending function. meaning that you can add stuff on the lines that will blend one animation to another including how far into one animation and when to pickup in another. this will help for units and leaders coming from civ4 since they have far less animations.

    seondly, through the state graph you can add civ5 native effects to custom units. there is a list of effects (like fire arrows etc) and you can say in the stategraph what effect is to be used when.

    hope that helps.
     
  5. The_J

    The_J Say No 2 Net Validations Retired Moderator Supporter

    Joined:
    Oct 22, 2008
    Messages:
    30,839
    Location:
    Germany / Netherlands
    Moderator Action: Moved to tutorials.

    I promise you a cookie, if we could get a keshik before the 25th.
     
  6. lemmy101

    lemmy101 Chieftain

    Joined:
    Apr 10, 2006
    Messages:
    1,064
    PASTED FROM FIRST POST TO MAKE ROOM FOR WALKTHROUGH:

    Event Codes

    There are event codes which relate to specific 'events' that the model can animate, such as running or dying. These are nothing to do with the actual animations, but are called by the state-graph as events that your fxsxml file will then decide which anim it actually relates to. Below is the event codes for a rifleman:

    1000 - IdleA
    1020 - IdleA_Trans_IdleB
    1040 - FidgetA
    1100 - AttackA
    1120 - Charge_Run
    1140 - Charge_Attack
    1160 - AttackCityA
    1180 - AttackCityB
    1200 - DeathA
    1220 - DeathA_Idle
    1280 - Bombard_Defence
    1285 - Bombard_Defence_Idle
    1290 - Bombard_Defence_Idle_Trans_IdleA
    1400 - Run
    1440 - Stop_Run
    1450 - Shuffle
    1500 - Fortify
    1520 - Fortify_Idle
    1540 - Fortify_Idle_Fidget
    1560 - Fortify_Idle_Trans_Combat_Ready_Idle
    1580 - Fortify_Idle_Trans_IdleA
    1600 - Combat_Ready
    1620 - Combat_Ready_Idle
    1640 - Combat_Ready_Idle_Trans_IdleA
    1800 - Victory
    2000 - IdleB
    2020 - IdleB_Trans_IdleA
    2040 - FidgetB
    2100 - AttackB
    2200 - DeathB
    2220 - DeathB_Idle
    2440 - Stop_RunB

    This means that, to create a new unit, you can completely copy the state-graphs, animation triggers AND animation graphs for the rifleman. All (I say all) you would have to do is make sure that every one of these event codes was catered for. An idle animation in the fxsxml file could point at every single one of these event codes.

    The rifleman does this as follows:

    Code:
    <Animation file="Rifleman_Attack_City.gr2" ec="1160, 1180"/>
    
    Meaning it uses the same 'Rifleman_Attack_City.gr2' anim for both AttackCityA and AttackCityB.

    By adding your single animation to the fxsxml and putting EVERY one of the above event codes in as follows:

    Code:
    <Animation file="MyAnim.gr2" ec="1000, 1020, 1040, 1100, 1120, 1140, 1160, 1180, 1200, 1220, 1280, 1285, 1290, 1400, 1440, 1450, 1500, 1520, 1540, 1560, 1580, 1600, 1620, 1640, 1800, 2000, 2020, 2040, 2100, 2200, 2220, 2440"/>
    
    You can put a new animated model into the game using the rifleman's state graphs, animation triggers and animation graphs in entirety.

    Then you would be able to create new animations one by one and move the event codes in the fxsxml one by one into the new anims as you went, while always maintaining a working model that just happened to be playing idle for each of the missing animations.

    Binky has prepared a model and associated files of a character from a previous game we worked on.

    The gr2 was exported with Nexus (with the anim fix patch applied) from an FBX file with one 'running' anim, and then was loaded up in the Material Maker to add a new UnitShader_Skinned material assigned to the mesh with the correct DDS file.

    The Captain's fxsxml file is as follows:

    Code:
    <Asset>
      <Mesh file="Captain.gr2" source="Tool" />
      <Animation file="CaptainRun0000.gr2" ec="1000, 1020, 1040, 1100, 1120, 1140, 1160, 1180, 1200, 1220, 1280, 1285, 1290, 1400, 1440, 1450, 1500, 1520, 1540, 1560, 1580, 1600, 1620, 1640, 1800, 2000, 2020, 2040, 2100, 2200, 2220, 2440"/>
    	<AnimGraph file="RUN_CHARGE_SHUFFLE_TO_SHUFFLE_RUN_CHARGE.dge"/>
    	<AnimGraph file="IDLE_OFFSET_CONTINUE_TRUE_GRAPH.dge"/>
    	<AnimGraph file="FORTIFY_FIDGET_GRAPH.dge"/>
    	<AnimGraph file="ENTER_FORTIFY.dge"/>
    	<AnimGraph file="LEAVE_BOMBARD_DEFEND_TRANS_IDLE_A_GRAPH.dge"/>
    	<AnimGraph file="DEATH_FINAL_GRAPH.dge"/>
    	<AnimGraph file="BOMBARD_DEFEND_LOOP_GRAPH.dge"/>
    	<AnimGraph file="ENTER_BOMBARD_DEFEND_GRAPH.dge"/>
    	<AnimGraph file="DEATH_GRAPH.dge"/>
    	<AnimGraph file="LEAVE_COMBAT_READY.dge"/>
    	<AnimGraph file="ENTER_COMBAT_READY_GRAPH.dge"/>
    	<AnimGraph file="FORTIFY_LEAVE_GRAPH.dge"/>
    	<AnimGraph file="COMBAT_READY_GRAPH.dge"/>
    	<AnimGraph file="FORTIFY_GRAPH.dge"/>
    	<AnimGraph file="TRANSITIONS_FOR_IDLES.dge"/>
    	<AnimGraph file="STOP_RUNNING.dge"/>
    	<AnimGraph file="IDLE_GRAPH.dge"/>
    	<AnimGraph file="FIDGETS_GRAPH.dge"/>
    	<AnimGraph file="MELEE_ATTACKS.dge"/>
    	<StateMachine file="1_OMNI_STATE_01.fsmxml"/>
    	<AnimGraph file="RUN_CHARGE_SHUFFLE_LOOP.dge"/>
    	<AnimGraph file="ATTACK_TO_RUN_CHARGE_SHUFFLE.dge"/>
    	<AnimGraph file="ATTACK_CITY_TO_RUN_CHARGE_SHUFFLE.dge"/>
    	<AnimGraph file="START_RUN_CHARGE_SHUFFLE.dge"/>
    	<AnimGraph file="SHUFFLE_STOP_GRAPH.dge"/>
    	<TimedTrigger file="FX_Triggers_Captain.ftsxml"/>
    </Asset>
    
    Note we have copied the FX_Trigger_Rifleman.ftsxml (the anim trigger file) and renamed the copy, and referenced that copy in this file. This may or may not be necessary but is advised in case you want to make changes to it later. All the other stuff, apart from the mesh / anim obviously, is pasted directly from the rifleman's fxsxml file.

    Just want to finish with saying that obviously a huge part of working all this out was CaptainBinky, we both worked for many many hours together trying to get here. Also big thanks to wirapuru, Deliverator and Ekmek and everyone else who contributed along the way!
     
  7. blazekid87

    blazekid87 Chieftain

    Joined:
    Oct 5, 2010
    Messages:
    179
    Location:
    NYC
    you got it! good job!
    I was pretty close. Only thing I missed was adding all the codes to a single animation.
     
  8. lemmy101

    lemmy101 Chieftain

    Joined:
    Apr 10, 2006
    Messages:
    1,064
  9. blazekid87

    blazekid87 Chieftain

    Joined:
    Oct 5, 2010
    Messages:
    179
    Location:
    NYC
    still doesnt work for me :lol:
    wtf????:mad:
     
  10. jaldaen

    jaldaen Chieftain

    Joined:
    Feb 19, 2006
    Messages:
    467
    Awesome news Lemmy! Great work... now I just have to convince someone to make me a Portuguese explorer unit to replace the musketman. ;)
     
  11. lemmy101

    lemmy101 Chieftain

    Joined:
    Apr 10, 2006
    Messages:
    1,064
    What happens for you now?

    I can only guess this is related to your FBX or model set-up somehow. :\
     
  12. Deliverator

    Deliverator Graphical Hackificator

    Joined:
    Feb 12, 2008
    Messages:
    4,273
    Location:
    London, UK
    Brilliant stuff. Now we're flying! Can't wait to have a go.

    It's good that you can reuse the same animation for multiple actions so easily.
     
  13. blazekid87

    blazekid87 Chieftain

    Joined:
    Oct 5, 2010
    Messages:
    179
    Location:
    NYC
    same thing as before...they're stuck half-way into the ground and rotated to the left by 90* lol.
     
  14. lemmy101

    lemmy101 Chieftain

    Joined:
    Apr 10, 2006
    Messages:
    1,064
    Odd. Binky's model was exported with Max, so if you're using Blender perhaps that's where the problem comes from.
     
  15. blazekid87

    blazekid87 Chieftain

    Joined:
    Oct 5, 2010
    Messages:
    179
    Location:
    NYC
    no im using max as well... created using the classic max biped. The animation is blank, but even so that should not be the problem since it is an animation file.

    Any way possible for you to upload your model as an example?
     
  16. lemmy101

    lemmy101 Chieftain

    Joined:
    Apr 10, 2006
    Messages:
    1,064
    Can't do really, the model is part of a commercial title we made the rights are a bit unclear. Fine to post screenshots of but we couldn't give away the model, sorry. :(

    Did you reset the XForm? Also you could try putting a dummy root bone at the origin and parenting biped to that?
     
  17. blazekid87

    blazekid87 Chieftain

    Joined:
    Oct 5, 2010
    Messages:
    179
    Location:
    NYC

    XForm? Dummy root bone?:eek:


    heres the assets when opened with nexus. this is after the build by modbuddy. maybe i missed something?
     
  18. CaptainBinky

    CaptainBinky Chieftain

    Joined:
    May 12, 2010
    Messages:
    264
    Location:
    UK
    Hi blazekid87,

    Resetting the XForm

    Select your mesh
    Click the modify tab to show the stack
    Turn off the skin (click the lightbulb next to the Skin modifier in the stack panel. It should go grey)
    Click on "Utilities" (the hammer tab at the top of the stack panel)
    Click on "Reset XForm"
    Click "Reset Selected"
    Go back to the stack view (click the modifier tab again)
    Drag the XForm modifier to underneath the skin modifier
    Right-click on the XForm modifier
    Click "Collapse to"
    Turn back on the skin

    Making a dummy root-bone

    Click the "create" tab (left-most tab on the stack panel)
    Select "helpers" from the buttons under those tabs (it's second from right)
    Click "Dummy"
    Create one in the 3D view
    Press "W" to pick the move tool
    In the status bar down the bottom of the screen are X, Y, and Z input boxes
    Type "0" in each of those to move the dummy to the origin
    Select the root biped bone
    Click the "Select and link" button (immediately under the file menu - looks like a linked chain)
    Click and drag from the biped root to the dummy to link

    ...and after all that, export again.
     
  19. WarKirby

    WarKirby Arty person

    Joined:
    Jul 13, 2006
    Messages:
    5,317
    Location:
    Glasgow, Scotland
    ^___^

    I will try this when I get the time, has it been tested with blender or is it an assumption that it will work?
     
  20. blazekid87

    blazekid87 Chieftain

    Joined:
    Oct 5, 2010
    Messages:
    179
    Location:
    NYC
    Im sorry Im not sure what you mean. What is the root biped bone?
     

Share This Page