Jump to content

A20 - Consolidated Guide to Modding with Unity


xyth

Recommended Posts

A20 - Consolidated Guide to Modding 7D2D with Unity

 

First off, a disclaimer. I started modding and using Unity a few years ago when A16 was the current build, so I am not a Unity Pro. I have no formal training in using it, so the way I do things may well seem ugly to some folks more versed than I, but I can claim that the things I make in Unity work well. Hopefully after these tutorials yours will too, and eventually you can teach others a better way of doing things.

 

What you need to get started

 

1. Install the Version of Unity that matches the version of the game you want to mod. For A20, you need Unity 2020.3.xx or , for A19 you needed 2019.2.  How do you know which version to download? The game creates log files (Player.log and Output_Log that has a line near the top like this: Initialize engine version: 2019.1.0f2 (292b93d75a2c). That was A18.4, and you see it was built with Unity 2019.1   You can find all the versions of unity for the current and all previous alphas at https://unity3d.com/get-unity/download/archive 

 

2. Download the A20 Tutorial Unity project from my repo at https://drive.google.com/file/d/1DsFR0e1V-f0bNiZDAuVd0kb7_iYtyNqL/view?usp=sharing 

For A20 the current template is called: A20TutorialProject.zip

 

Terms of Use

 

  1. You are allowed to use the A20 Tutorial Project, including its custom Unity character Controller without any kind of direct modifications.  However, all modifications and/or use of A20 Unity character Controller contained in the A20 Tutorial Project and controller is restricted to private use only unless those modifications are done for use in other mods that have a dependency on the unaltered NPCCore mod (XNPCCore) being loaded with that other mod..  The controller contains purchased animations, so any derivative use of the models or controller is also contingent on purchasing those assets first.

 

Start up your copy of Unity 2020.3.x and load that tutorial project into it.  It is preconfigured for success, including the TagManager used by TFP, the MultiPlatformExport script, and templates for vehiles, characters, flags, guns and more.

 

Visual learner?   Watch some of these videos to help get you started.

 

https://www.youtube.com/channel/UCUAR3Bc_Z97lyT4zeI3-dcg/playlists

 

If you have questions, feel free to ask. We do expect that you watch all the relevant videos and understand the basics shown in them before asking questions. The best way to learn is to try to do it yourself first, then if your stuck we are here to help.

 

If anyone makes other Unity videos relevant to this game, please let me know so I can link it here.

 

Here are a few sample videos.  You can find more at the link above.

 

Weapon Positioning in Unity

Simple video showing how to align weapons so they sit in players hand properly

 

 

 

Mecanim Animation

How to make doors and other things move in game

 

 

 

 

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

  • 7 months later...

Would this work to open up old (A15.2 and maybe A8(I think)) assets for exporting? (I have never even looked at Unity for models or assets)

I want to bring out some sounds from A15.2 (eventually zombieskins too(missing the old classic versions))

Aswell as grab the titlemusic from A8 :D

Or is there better tools for that?

UABE seemed to not handle assets from what I could understand

 

Link to comment
Share on other sites

  • xyth pinned this topic
  • xyth changed the title to A20 - Consolidated Guide to Modding with Unity
  • 3 weeks later...

Hoping someone can help with a Unity problem I'm having.  Been messing around trying to learn, downloaded @xyth's A20 Tutorial package, which I have no problem using the premade items and importing them properly into my test mod.  I was experimenting with a free melee weapon file I found online (just a generic mace) which I wanted to see about making similar to the baseball bat weapon.  The file I imported was a .fbx model, I added some textures to it, aligned it with the same orientation and rough size as the template wooden club.  The prefab parent object is set to all defaults. The XML file for the weapon I created works perfectly with the template club (no code changes, just the meshfile).  However when I use the mace prefab and equip it, the character view in game is all janky.  It's basically rotated like 160 degrees, and at a slight angle (I see the characters arms, gripping the mace on the handle properly, but just all jacked up).  The view on equipping is both arms, looking at the character like you're standing in front of him, but just floating arms.

 

Any idea what my problem could be?

 

UPDATE: Apparently the .fbx file was the problem.  The model I got also had a .obj file, which I imported to Unity, aligned with the club, and viola...the character in game is holding it properly.  I still have absolutely no idea why the file type imported would have an effect on the exported unity3d file, so if anyone can provide some insight, I'd love to know.

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

6 hours ago, SavageSaffron said:

UPDATE: Apparently the .fbx file was the problem.  The model I got also had a .obj file, which I imported to Unity, aligned with the club, and viola...the character in game is holding it properly.  I still have absolutely no idea why the file type imported would have an effect on the exported unity3d file, so if anyone can provide some insight, I'd love to know.

 

I am also very new to this, so this may be completely off base; I did however have a similar experience when I first imported a model though. In my case I had left a camera in the items scene (Which I had added myself while messing about), that was all kinds of messed up when the item was equipped!

 

Could potentially have been one added during the import or some such?

Link to comment
Share on other sites

3 hours ago, Ananais said:

 

I am also very new to this, so this may be completely off base; I did however have a similar experience when I first imported a model though. In my case I had left a camera in the items scene (Which I had added myself while messing about), that was all kinds of messed up when the item was equipped!

 

Could potentially have been one added during the import or some such?

 

I hadn't considered a camera being a problem.  The .fbx did have a "Render Camera" at the bottom of the list and I didn't give it any thought.  I'll try removing that from the prefab and see if that could have been the problem with that model.  The .obj model did not have any cameras or lighting effects loaded in it.

Link to comment
Share on other sites

  • 1 month later...

I'm currently having an issue where any object I create is unable to be interacted with(i.e. can't hit it with a melee weapon to break it). I've narrowed it down to something in the creation of the unity asset bundle, but I'm at a loss for what I'm missing. I have exported the TutorialCube from the example unity project using the provided asset bundling script as my test object. However, if I take an already compiled asset bundle for the model of the item in-game, it is fully interactable. Any ideas?

Link to comment
Share on other sites

  • 3 weeks later...
  • 6 months later...
  • 2 months later...
  • 8 months later...
  • 5 months later...

I have attempted to add a sniper rifle to the game. The pink mesh was standing up on its nose, so I scaled and positioned accordingly. I exported the .unity3d file.

 

The path is Mods>My Rifle Attempt>resources>the unity file

 

What is happening is I'm getting the object not set to reference of an object error. I am also getting the error that says there is no transform called "Attachments".

 

I did create an empty object for the prefab. I went back after the first round of errors and created another empty object called "Attachments" and added that to the prefab to store the scope. The scope is the only attachment. I am just trying to get the gun in the game and rotated properly. I was going to start with that and then add attachments and whatnot.

 

I'm not sure what I've done wrong at this point.

 

It does show up in the game. I just used a tinted icon from the regular sniper rifle in the game. When I try to pull it out, I get the error. The player is holding an invisible gun that does nothing.

 

<item name="SniperRifle_SS">
            <property name="CustomIcon" value="gunRifleT3SniperRifle"/>
            <property name="CustomIconTint" value="#50C878"/>
            <property name="Tags" value="weapon,ranged,holdBreathAiming,reloadPenalty,gun,barrelAttachments,sideAttachments,smallTopAttachments,mediumTopAttachments,largeTopAttachments,stock,magazine,firingMode,bottomAttachments,attPerception,perkDeadEye,attachmentsIncluded,canHaveCosmetic,rifleSkill"/>
            <property name="DisplayType" value="rangedGun"/>
            <property name="HoldType" value="77"/>
            <property name="Meshfile" value="#@modfolder:Resources/SniperRifle_SS.unity3d?SniperRifle_SS"/>

 

Maybe the path for my Mesh file is incorrect? I got this from another mod that added an axe to the game and just tried the path, so it is likely my own fault, but I'm not sure how to do this at all.

 

Edit:

I also tried this:

<property name="Meshfile" value="#@/Mods/My Rifle Attempt/resources/SniperRifle_SS.unity3d"/>

 

Edited by ChrisWoodward
Adding more information (see edit history)
Link to comment
Share on other sites

3 hours ago, ChrisWoodward said:

I have attempted to add a sniper rifle to the game. The pink mesh was standing up on its nose, so I scaled and positioned accordingly. I exported the .unity3d file.

 

The path is Mods>My Rifle Attempt>resources>the unity file

 

What is happening is I'm getting the object not set to reference of an object error. I am also getting the error that says there is no transform called "Attachments".

 

I did create an empty object for the prefab. I went back after the first round of errors and created another empty object called "Attachments" and added that to the prefab to store the scope. The scope is the only attachment. I am just trying to get the gun in the game and rotated properly. I was going to start with that and then add attachments and whatnot.

 

I'm not sure what I've done wrong at this point.

 

It does show up in the game. I just used a tinted icon from the regular sniper rifle in the game. When I try to pull it out, I get the error. The player is holding an invisible gun that does nothing.

 

<item name="SniperRifle_SS">
            <property name="CustomIcon" value="gunRifleT3SniperRifle"/>
            <property name="CustomIconTint" value="#50C878"/>
            <property name="Tags" value="weapon,ranged,holdBreathAiming,reloadPenalty,gun,barrelAttachments,sideAttachments,smallTopAttachments,mediumTopAttachments,largeTopAttachments,stock,magazine,firingMode,bottomAttachments,attPerception,perkDeadEye,attachmentsIncluded,canHaveCosmetic,rifleSkill"/>
            <property name="DisplayType" value="rangedGun"/>
            <property name="HoldType" value="77"/>
            <property name="Meshfile" value="#@modfolder:Resources/SniperRifle_SS.unity3d?SniperRifle_SS"/>

 

Maybe the path for my Mesh file is incorrect? I got this from another mod that added an axe to the game and just tried the path, so it is likely my own fault, but I'm not sure how to do this at all.

 

Edit:

I also tried this:

<property name="Meshfile" value="#@/Mods/My Rifle Attempt/resources/SniperRifle_SS.unity3d"/>

 

 

Another Edit (I guess you can only do one):

 

I switched to a pistol and got it to work. The code is all fine. The problem now is there is no texture. Just a white gun. I'm not sure what to do about that as all tutorials just say to export the prefab.

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