• If you have a mod, tool or prefab, please use the Resources section. Click Mods at the top of the forums.

Creating and Exporting Models from Unity for use in 7D2D

Updating for A21

Here are the links you will need to get started modding A21 using Unity. You must use Unity 2021.3 to create new assets for A21.  

Things you will need to follow along with the videos (note that the video talks about old version of unity but it is the same process).  

Step 1:  Download the Unity Hub and Unity 2021.3.19f1:  https://unity3d.com/get-unity/download/archive

then Install it.

Step 2:  Download my Unity 2021.3 template projecthttps://drive.google.com/file/d/1yPQ2yOj1Oe7pOml3ytfZcNggWWTAD4gq/view?usp=sharing then unpack it, saving it to a location you will remember.  

Step 3:  Open unity Hub, and click the ADD button, locate my project template, and select that folder. 

You now have a properly configured modding platform.  The project includes the TFP tagmanager, Linear lighting configuration, and the export script needed to export your new things as .unity3d bundles.  

Step 4:  Go watch the tutorial videos.

https://www.youtube.com/user/xythq/playlists?shelf_id=0&view=1&sort=dd

Step 5:   Make something cool, and have fun doing it! 

 
Last edited by a moderator:
Well, the tutorial was done a while ago, so for A19 you need to use the A19 version of Unity and the A19 version of the controller.   The process remains the same, though little things change every alpha.  I will release an updated tutorial project and controller for A20, the A19 stuff is already available.  I suggest joining Guppys modding Discord if you have specific questions and for links to where new versions are.

 
I'm trying to put the old hunting rifle back in the game. I exported the prefab from A19 that items.xml refers to. Put it into unity. Looks fine, textures are all where they should be etc. I dragged the HuntingRiflePrefab.fbx into hierarchy, then dragged it back into the project folder as a .prefab. Exported to .unity3d. Set meshfile path, which seems correct as if I set it differently I get errors and don't even see the hands. Yet when I load up the game, the rifle is invisible. Only see the hands. Any ideas where to troubleshoot?

Would think I'd get a purple mesh if the materials weren't loading. Instead I get nothing. Unless perhaps it IS there and the positioning is just way off if they changed where the rifle is positioned in A20.

 
I'm trying to put the old hunting rifle back in the game. I exported the prefab from A19 that items.xml refers to. Put it into unity. Looks fine, textures are all where they should be etc. I dragged the HuntingRiflePrefab.fbx into hierarchy, then dragged it back into the project folder as a .prefab. Exported to .unity3d. Set meshfile path, which seems correct as if I set it differently I get errors and don't even see the hands. Yet when I load up the game, the rifle is invisible. Only see the hands. Any ideas where to troubleshoot?

Would think I'd get a purple mesh if the materials weren't loading. Instead I get nothing. Unless perhaps it IS there and the positioning is just way off if they changed where the rifle is positioned in A20.
Don't take my advice as a specialist, but...

Try to check the Scale of the object - throw it on the ground.

And, perhaps, a shift from the coordinates - look carefully at yourself from the third person view and look underground.

I'm also going to do a similar return of old weapons, but Iihaven't engage yet. Please tell us what you will end up with.

(I see you use a translator, what is your main language?)

 
Last edited by a moderator:
No, no translator.

I'm just not having any luck. I thought maybe it was because I was using the old version of Unity so I updated, still no luck. Let me just go through the process I'm doing.

I export the .prefab that the items.xml meshfile path refers to in the items bundle. It gives me a folder containing the textures (materials) and huntingrifleprefab.fbx rather than an actual .prefab file. So I pull all these files into Unity. Drag the .fbx into the hierarchy. Then I drag the parent object from the hierarchy back into the project area which creates a .prefab. Right-click on the new .prefab and use the export script - Build AssetBundle From Selection, to create the .unity3d. Then change the meshpath to reference it with xpath.

Now I've tried a bunch of variations on this, nothing is working. I tried going thirdperson and looking all around, model is nowhere to be found. All I get in-game are the hands. I don't know if I'm missing somewhere along the way involving:

- Exporting the .prefab with AssetStudio. Do I need a certain option turned on in the Export Options?
- Turning the .fbx into a prefab in Unity
- I imported the new rifle model into Unity to see if that helped me figure anything out. Noticed the new rifle has 3 LOD meshes, maybe the game is looking for a specific mesh name, or requires 3 LODs to function?

Edit: Out of curiosity I tried using the same process with the new hunting rifle to see if I could get that back in game. Except when I do this I get NREs. So I must be doing something wrong in my process.

 
Last edited by a moderator:
....
I export the .prefab that the items.xml meshfile path refers to in the items bundle. It gives me a folder containing the textures (materials) and huntingrifleprefab.fbx rather than an actual .prefab file. So I pull all these files into Unity. Drag the .fbx into the hierarchy. Then I drag the parent object from the hierarchy back into the project area which creates a .prefab. Right-click on the new .prefab and use the export script - Build AssetBundle From Selection, to create the .unity3d. Then change the meshpath to reference it with xpath.
///
Yes, it goes without saying, it makes no sense to describe how you got the object inside Unity.  If you see there in an acceptable form - then it can be workable in the game.

But there are various hierarchies and parameters, tags that need to be observed. This can be checked only by seeing the settings of the prefab that is located in Unity editor.

It will be more useful to show exactly this. And, you have never published what is contained in the error message.

As i advised you in another thread - make a primitive object (cube, stick) and try to get it in the game, in your hands.

(do not use another fbx that you pulled out using AssetStudio!)

PS: You don't have to use the LODs. You can only use LOD0. Just remove the rest.

 
Last edited by a moderator:
I got the model in the game but not in an ideal way. I pulled in the .fbx but also the _mesh .obj extracted from the bundle, then replaced the mesh reference with the .obj. It tells me the assigned mesh is missing bone weights and to set it to mesh renderer instead of skinned mesh renderer, so I did that. Also unpacked the materials from the .fbx and reassigned them to the mesh. Weirdly the .obj is much larger than the mesh contained in the .fbx despite the scale being set the same? In-game it works, just needs moved forward a bit. The main problem now is idk how to get the animations working. It seems like all the bone and animation data is packed in the .fbx and doesn't get extracted separately by AssetStudio. And the bone info is packaged with the .fbx.

Like I guess with enough trial and error I can just rebuild the prefab with the mesh files and such, maybe even figure out how to redo the bones on the mesh and transfer the animations over. But surely there is an easier way to do this? You can't just export a .fbx and reimport it the way it was bundled in the first place? Does information get lost when you extract a prefab with AssetStudio or something?

 
Last edited by a moderator:
Oh my god. The fact that the .obj was much larger made me think the scale was way off. I also looked up KhaineGB's video again. It was age restricted, not removed. Yea, that was it...He says you have to up the scale to 100 when you export the .fbx from AssetStudio. So now I have the .fbx repackaged and visible in-game. Now I just have to see if I can figure out how to get the animations working.

When I import the .fbx I get an error that HuntingRifle_Mesh has vertices with no weight and bone assigned. It seems like AssetStudio isn't preserving which parts of the mesh are assigned to bones when exporting. I can play the animation in Unity and I see the individual transforms moving properly, eg Bolt_End and the Bullet transforms, but the transforms aren't actually assigned/linked to any parts of the mesh. If I move the Bullet transform around in Unity, the actual bullet part of the mesh doesn't move with it. I was searching around inside Unity and I have no idea how to assign vertices. It almost seems like I'd need to open up the .obj in Blender and fix this there, unless there's something I'm missing.

EDIT: Well, it seems that the issue is only with the A19 version of the hunting rifle. I also have an A16 install sitting on my drive. I exported that version of the hunting rifle and what do you know, the bolt and bullet are actually separate objects and are attached to their transforms. The cool thing is, since everything is named the same, I can easily use the cleaned up A19 bolt cycle animation on the A16 rifle.

 
Last edited by a moderator:
I got everything figured out. Just want to compile a bunch of random info related to getting models in-game that was either scattered around outside of this thread or I couldn't find myself.

Extracting and Re-Importing prefabs:

- When you extract prefabs with AssetStudio I found it better to go to Options > Export options and set Group exported assets by "container path". This keeps things organized in the same hierarchy as the bundles.

- As mentioned in KhaineGB's video linked below, when you export prefabs with AssetStudio (weapon prefabs, at least), after you bring them into Unity and drag them into the hierarchy, you need to set the root prefab's X, Y, and Z scale to 100 to bring them back to their proper size. Alternatively, before exporting, you could go to Export options in AssetStudio and change the ScaleFactor to 100.

- When you import say a weapon prefab .fbx and you want to repackage it, after you've got it pulled into the hierarchy to create a new prefab, I found it good to break out the assets packed into the original imported prefab. Click on the arrow next to original prefab in Projects area, click on say a mesh or material, then press Ctrl+D. This will extract it out of the prefab. Then change all the references to meshs, materials etc. in the new prefab you made in the hierarchy to the separated out assets. Once you're done you can drag the new prefab back into the Projects area and Export that. This way when you rebundle it, it rebundles only the assets you need and you don't have duplicate prefabs taking up file space.

- Certain extracted prefabs imported into Unity don't have parts of the mesh rigged properly to the transform nodes, which means broken animations. It's very inconsistent, some models import with everything assigned correctly while others don't. Not sure why or how to fix this yet.

Materials & Textures:

- When you reimport a prefab .fbx into Unity, the materials default to standard Shader and the materials only assign the albedo and normal. You want to change Shader to Autodesk Interactive, this will give you a slot for the roughness map. Then you can assign your material's metallic map (_m), roughness map (_r), occlusion map (_ao/_o) etc. Some of the new A20 prefabs use a new system for this where all 3 + emissivity are combined into one texture (_fmom?). I suppose you could split out the color channels into separate textures until we have a proper shader to handle these?

- Along with making sure Unity is set to use linear lighting (you can google this quickly), be sure also in the texture settings (not the material, the textures themselves) you disable sRGB (Color Texture) on everything except the Albedo, to align with the linear lighting. This fixed my issue where my weapon was abnormally shiny.

- Old style normal maps (purple-ish) seem to work fine set to Texture Type: Normal Map as Unity bugs you to. But for the newer pinkish normal maps with alpha channels, I found ignoring Unity warnings and keeping them set to Default with sRGB disabled and Alpha Source: Input Texture Alpha seemed to produce an outcome that looks most like the default weapons.

Animations:

- Imported prefabs don't include animator settings, but the animations are in there if you expand the arrow. Once you pull the prefab into the hierarchy, you can then drag the animation you need onto the hierarchy prefab. You want it on the root prefab, not the 2nd level, or the animation references will be one level off and show in yellow. KhaineGB's video goes over this:
https://community.7daystodie.com/topic/10338-adding-new-guns-to-7-days-to-die-a17/

- The "Sdx Ranged Weapon advanced Tutorial" on page 1 of this thread goes over setting up animator triggers. But being an older video it doesn't mention that you also need to add a parameter so the game scales your reload speeds according to reload speed modifiers on your character. You need to add a float parameter named "ReloadSpeed" set to 1, then on your reload animator state set the speed multiplier to this parameter.

 
Last edited by a moderator:
Thank You so much for summing up our research! :)

I would advise you to duplicate this in the first post of your topic with the appropriate title. People who need it can more easily find this information there.

 
Is the info in the original post up-to-date for a20? Still unity version 2019.2.21? 

edit: Nevermind, I got it. Sorry.

 
Last edited by a moderator:
Hey @xyth! I followed your tutorials and made about 6 zombie models. I put one through Unity after a Mixamo rigging. It animates fine in Unity but it only t-poses in game. It senses me and spins around if I bump into it, and if I run into one of its hands it damages me, but it doesn't move on its own. The only thing I know I didn't add in Unity was LOD 0. Besides that, would you have any idea what I might be missing?

Let me know if there's anything I need to provide. 

EDIT: Here's everything I can think that might show something

Entity classes XML

<configs>

<append xpath="/entity_classes">

<entity_class name="Male_Nurse_GG_Zombie" extends="zombieTemplateMale">
<property name="UserSpawnType" value="Menu"/>
<property name="Tags" value="entity,zombie,normal"/>
<property name="Mesh" value="#@modfolder:Resources/Male_Nurse_GG_Zombie.unity3d?Male_Nurse_GG_Zombie"/>
<property name="AvatarController" value="AvatarZombieController"/>
<property name="PhysicsBody" value="mixamoBasicRig"/>
<property name="WalkType" value="7"/>
<property name="RootMotion" value="true"/>
<property name="HandItem" value="meleeHandZombie01"/>
<property name="HandItemCrawler" value="meleeHandZombie01"/>
<property name="RightHandJointName" value="RightHand"/>
<property name="LootDropProb" value="0.05"/>
<property name="DeadBodyHitPoints" value="1000"/>
<effect_group name="Base Effects">
<passive_effect name="DistractionResistance" operation="base_set" value="0,0"/>
<passive_effect name="HealthMax" operation="base_set" value="150"/>
<passive_effect name="HealthMax" operation="perc_set" value="1"/>
<passive_effect name="StaminaMax" operation="base_set" value="100"/>
<passive_effect name="PhysicalDamageResist" operation="base_set" value="0"/>
</effect_group>
<property name="Mass" value="120"/>
<property name="Weight" value="200"/>
<property name="SizeScale" value="1.1"/>
</entity_class>

</append>

</configs>






Physics bodies XML

<configs>
<append xpath="/bodies">
<body name="mixamoBasicRig">
<collider>
<property name="tag" value="E_BP_Body"/>
<property name="path" value="Hips"/>
<property name="collisionLayer" value="0"/>
<property name="ragdollLayer" value="0"/>
<property name="collisionScale" value="1 1 1"/>
<property name="ragdollScale" value="0.75 0.39 1"/>
<property name="collisionOffset" value="0 0 0"/>
<property name="ragdollOffset" value="0 0 -0.08"/>
<property name="type" value="Detail"/>
<property name="flags" value="collision;ragdoll"/>
</collider>
<collider>
<property name="tag" value="E_BP_LLeg"/>
<property name="path" value="Hips/LeftUpLeg"/>
<property name="collisionLayer" value="0"/>
<property name="ragdollLayer" value="0"/>
<property name="collisionScale" value="1 1 1"/>
<property name="ragdollScale" value="1 1 1"/>
<property name="collisionOffset" value="0 0 0"/>
<property name="ragdollOffset" value="0 0 0"/>
<property name="type" value="Detail"/>
<property name="flags" value="collision;ragdoll"/>
</collider>
<collider>
<property name="tag" value="E_BP_LLowerLeg"/>
<property name="path" value="Hips/LeftUpLeg/LeftLeg"/>
<property name="collisionLayer" value="0"/>
<property name="ragdollLayer" value="0"/>
<property name="collisionScale" value="1 1 1"/>
<property name="ragdollScale" value="1 1 1"/>
<property name="collisionOffset" value="0 0 0"/>
<property name="ragdollOffset" value="0 0 0"/>
<property name="type" value="Detail"/>
<property name="flags" value="collision;ragdoll"/>
</collider>
<collider>
<property name="tag" value="E_BP_RLeg"/>
<property name="path" value="Hips/RightUpLeg"/>
<property name="collisionLayer" value="0"/>
<property name="ragdollLayer" value="0"/>
<property name="collisionScale" value="1 1 1"/>
<property name="ragdollScale" value="1 1 1"/>
<property name="collisionOffset" value="0 0 0"/>
<property name="ragdollOffset" value="0 0 0"/>
<property name="type" value="Detail"/>
<property name="flags" value="collision;ragdoll"/>
</collider>
<collider>
<property name="tag" value="E_BP_RLowerLeg"/>
<property name="path" value="Hips/RightUpLeg/RightLeg"/>
<property name="collisionLayer" value="0"/>
<property name="ragdollLayer" value="0"/>
<property name="collisionScale" value="1 1 1"/>
<property name="ragdollScale" value="1 1 1"/>
<property name="collisionOffset" value="0 0 0"/>
<property name="ragdollOffset" value="0 0 0"/>
<property name="type" value="Detail"/>
<property name="flags" value="collision;ragdoll"/>
</collider>
<collider>
<property name="tag" value="E_BP_Body"/>
<property name="path" value="Hips/Spine/Spine1/"/>
<property name="collisionLayer" value="0"/>
<property name="ragdollLayer" value="0"/>
<property name="collisionScale" value="1 1 1"/>
<property name="ragdollScale" value="1 0.36 1"/>
<property name="collisionOffset" value="0 0 0"/>
<property name="ragdollOffset" value="0 0.05 -0.08"/>
<property name="type" value="Detail"/>
<property name="flags" value="collision;ragdoll"/>
</collider>
<collider>
<property name="tag" value="E_BP_LArm"/>
<property name="path" value="Hips/Spine/Spine1/Spine2/LeftShoulder/LeftArm"/>
<property name="collisionLayer" value="0"/>
<property name="ragdollLayer" value="0"/>
<property name="collisionScale" value="1 1 1"/>
<property name="ragdollScale" value="1 1 1"/>
<property name="collisionOffset" value="0 0 0"/>
<property name="ragdollOffset" value="0 0 0"/>
<property name="type" value="Detail"/>
<property name="flags" value="collision;ragdoll"/>
</collider>
<collider>
<property name="tag" value="E_BP_LLowerArm"/>
<property name="path" value="Hips/Spine/Spine1/Spine2/LeftShoulder/LeftArm/LeftForeArm"/>
<property name="collisionLayer" value="0"/>
<property name="ragdollLayer" value="0"/>
<property name="collisionScale" value="1 1 1"/>
<property name="ragdollScale" value="1 1 1"/>
<property name="collisionOffset" value="0 0 0"/>
<property name="ragdollOffset" value="0 0 0"/>
<property name="type" value="Detail"/>
<property name="flags" value="collision;ragdoll"/>
</collider>
<collider>
<property name="tag" value="E_BP_RArm"/>
<property name="path" value="Hips/Spine/Spine1/Spine2/RightShoulder/RightArm"/>
<property name="collisionLayer" value="0"/>
<property name="ragdollLayer" value="0"/>
<property name="collisionScale" value="1 1 1"/>
<property name="ragdollScale" value="1 1 1"/>
<property name="collisionOffset" value="0 0 0"/>
<property name="ragdollOffset" value="0 0 0"/>
<property name="type" value="Detail"/>
<property name="flags" value="collision;ragdoll"/>
</collider>
<collider>
<property name="tag" value="E_BP_RLowerArm"/>
<property name="path" value="Hips/Spine/Spine1/Spine2/RightShoulder/RightArm/RightForeArm"/>
<property name="collisionLayer" value="0"/>
<property name="ragdollLayer" value="0"/>
<property name="collisionScale" value="1 1 1"/>
<property name="ragdollScale" value="1 1 1"/>
<property name="collisionOffset" value="0 0 0"/>
<property name="ragdollOffset" value="0 0 0"/>
<property name="type" value="Detail"/>
<property name="flags" value="collision;ragdoll"/>
</collider>
<collider>
<property name="tag" value="E_BP_Head"/>
<property name="path" value="Hips/Spine/Spine1/Spine2/Neck/Head"/>
<property name="collisionLayer" value="0"/>
<property name="ragdollLayer" value="0"/>
<property name="collisionScale" value="1 1 1"/>
<property name="ragdollScale" value="0.8 0.88 1"/>
<property name="collisionOffset" value="0 0 0"/>
<property name="ragdollOffset" value="0 0.02 0"/>
<property name="type" value="Detail"/>
<property name="flags" value="collision;ragdoll"/>
</collider>
</body>
</append>
</configs>




Unity folder hierarchy

image.png

image.png

What it looks like in game

image.png

And the error message I get from the log

"NullReferenceException: Object reference not set to an instance of an object
  at (wrapper dynamic-method) EModelBase.DMD<EModelBase::LookAtUpdate>(EModelBase)
  at EModelBase.LateUpdate () [0x0001e] in <a58aca9c8ed54d639b41f6dc2ac2f31b>:0 "

I can post the complete log if needed, though there doesn't seem to be anything different (besides this error) when comparing it logs without the zombie mod.

 
Last edited by a moderator:
Did you remember to change the fbx to humanoid?  The XML error is likely unrelated, probably needs the lookat property set up zero. 

 
Did you remember to change the fbx to humanoid?  The XML error is likely unrelated, probably needs the lookat property set up zero. 
I'm pretty sure it's set to humanoid. I don't know how to check now that it's a prefab though. 

And I also tried to make a different zombie. This time I followed the tutorial based on the scripts. It's name shows up in the spawn menu, but it won't spawn. I click on it, hear the spawn sound and nothing shows up. I even tried to spawn it in the air, thinking that maybe it's spawning under the ground, but no.  

 
The log says "Lyndsey loves Mike" with a heart drawn around it. 

You figured this out weeks ago on Discord. Remember? Rename the FBX.

 
Back
Top