Jump to content

Creating and Exporting Models from Unity for use in 7D2D


xyth

Recommended Posts

51 minutes ago, rickyralph said:

Modded weapons are falling through the terrain. I created a mod for some weapons from the asset store in unity. The mod is complete and I am able to find them in the creative menu, I am able to hold them and fight with them. Everything looks good, except when i drop them they just fall through the terrain. My first guess was something wrong with the box collider, but have made changes with no changes in the game. My next guess is I am using the wrong tag "T_Mesh_B". I am honestly clueless about the tags though so I have no guess what to change it to. Any help would be appreciated.

If I may suggest a quick temporary fix:

 

In items.xml, try to put this line

<property name="DropMeshfile" value="#Other/Items?Misc/sack_droppedPrefab.prefab"/>

below your Meshfile property inside the weapon code.

Link to comment
Share on other sites

41 minutes ago, xyth said:

I uploaded a new A19 Project template to my repo:  https://github.com/7D2D/Templates-and-Utilities/blob/master/A19TemplateProject.zip

 

I also updated the first post for A19.

Thanks for updating this. You're always teasing us, making us want to create something new, but most of what I would love to create is beyond my abilities. :(

Link to comment
Share on other sites

1 hour ago, rickyralph said:

I figured it out thanks to xyth on the 7dtd discord channel. Items don't use tags or colliders and I think that was causing the weapons to ghost through the world when dropped. Thanks again xyth. But that's is good to know if I am having similar issues. Thanks mr.devolver.

No problem. Now that you figured it out, you should make some video tutorials for the rest of us to learn from. :p

Link to comment
Share on other sites

I can try to make a video, no promises. It's all dependent on time. I am also not good at it. more of just looking at how the xml files are configured and changing them to what I want. The unity videos xyth did a few years ago are still very relevant to now also. But I can try to put a video together of how to make a weapon from a unity asset and adding it into the game.

Link to comment
Share on other sites

14 hours ago, rickyralph said:

I can try to make a video, no promises. It's all dependent on time. I am also not good at it. more of just looking at how the xml files are configured and changing them to what I want. The unity videos xyth did a few years ago are still very relevant to now also. But I can try to put a video together of how to make a weapon from a unity asset and adding it into the game.

Cool! The more stuff we can learn from, the better, so I'm looking forward to your tutorial! :) By doing so, you will kill two birds with one stone. You will test your own skills, possibly learn, figure out something new in the process and you will also help others to learn something they didn't know. Maybe in your tutorial, you will give people the last piece of information they need to create a new awesome mod everyone always wanted to make and play, but couldn't create because they didn't know how! ;)

Link to comment
Share on other sites

I have a modular weapon and tool mod that uses item modifiers to swap out parts like heads, blades, grips, etc. I found that I have to add a box collider to the base item around where the blade will be for hits to register, and make sure that the item modifiers do not have colliders. Ymmv, but I have tested this extensively. 

Just picture an axe handle with no head but a box collider around the end. The various axeheads are cosmetic and add dmg in the xml.

Link to comment
Share on other sites

That's interesting.  It wasn't needed before but perhaps its needed now for the dynamic melee system to determine glancing blows.  The issue before was if a large weapon had a collider and it was in hand and you tried to climb up a ladder, you often got blocked from climbing.

Edited by xyth (see edit history)
Link to comment
Share on other sites

  • 10 months later...
  • 2 months later...

Hello, I'm very confused on how to create custom zombies and import them into 7d2d. I'm very familiar with importing assets and such from unity and have all of that set up already. I tried importing a zombie, the same one used in xyths' tutorial, into 7d2d with a walk animation... i ended up referring to the zombie male master and thought it would pull the animations that were needed from that, but when i spawned the zombie i got the classic "Object reference not set to an instance of an object" and nothing more. This is where i have been for quite a few hours. If you know of a good tutorial that goes through the steps of importing and setting up a zombie for 7d2d, that would be much appriciated. Thank you

 

Link to comment
Share on other sites

I did end up seeing this, however i dont think that it applies to the newest version of 7d2d. I followed step by step and everything went smooth. However when it came to testing in game, if i hit the zombie with melee attacks, it would stutter the animation and not transition to the next one. This would make the zombie un-damageable  and i would have to do killall. I found an irregularity with the zombie controller, where there is a tab in the newest version for forced animations when the zombie is hit. The older one doesn't have this. If you know a work around, or more likely if im doing something wrong, Please advise. Thank you!

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...

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.

Link to comment
Share on other sites

9 hours ago, Deceptive Pastry said:

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?)

Edited by n2n1 (see edit history)
Link to comment
Share on other sites

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.

Edited by Deceptive Pastry (see edit history)
Link to comment
Share on other sites

1 hour ago, Deceptive Pastry said:

....
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.

Edited by n2n1 (see edit history)
Link to comment
Share on other sites

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?

Edited by Deceptive Pastry (see edit history)
Link to comment
Share on other sites

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.

Edited by Deceptive Pastry (see edit history)
Link to comment
Share on other sites

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.

 

Edited by Deceptive Pastry (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...