Prefab not instantiating

Discuss modding questions and implementation details.
Post Reply
mwitz
Posts: 9
Joined: Mon May 30, 2022 8:17 am

Prefab not instantiating

Post by mwitz »

In my mod, I have a script component on the DaggerfallUnity prefab that instantiates a prefab in Start. When I run my mod in the Unity editor (using a scene with DaggerfallUnity and PlayerAdvanced), my prefab is instantiated, but when I load my mod in Daggerfall Unity, the prefab does not instantiate.

This leads me to believe that my understanding of the structure of mods is off. I tried to piece together some (seemingly outdated) tutorials. I first cloned down the Daggerfall Unity Github repository (https://github.com/Interkarma/daggerfall-unity). I then opened the repository as a project in Unity and edited it. I specifically edited a script and added a script component to DaggerfallUnity. I then used the Mod Builder under Daggerfall Tools, and built my mod. Then I put it in my mods folder, making sure it showed up in my mods list when I ran Daggerfall Unity (which it did). Is something off in my process here? I apologize if this is off, but I tried to follow the tutorials I could find online and this is what I could decipher.

Thanks a ton for the help.

User avatar
BadLuckBurt
Posts: 948
Joined: Sun Nov 05, 2017 8:30 pm

Re: Prefab not instantiating

Post by BadLuckBurt »

Do you have your code on Github or somewhere we can have a look? Some background information on what the mod / prefab does could also help to figure out the correct way to set up your mod.

The mod doesn't work because that script component you've added in the editor isn't present in the live build. You'd use the Init method from your mod's class to instantiate prefabs and add them to the scene (or if necessary attach that script component to the DaggerfallUnity prefab).

For example, this is my view distance / fog mod that only does stuff during it's Init call: https://github.com/BadLuckBurt/blb-clas ... ssicFog.cs. You would have to add something similar to your mod and then handle the prefab stuff from there. There are other states you can hook into as well so don't think it's all tied to Init.
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

.

mwitz
Posts: 9
Joined: Mon May 30, 2022 8:17 am

Re: Prefab not instantiating

Post by mwitz »

Thanks for the reply.

Ok I pushed what I did to GitHub if you want to take a look https://github.com/mwitz8/daggerfall-un ... player-mod. I literally forked the entire daggerfall-unity repository, and then edited the entire repository to make my mod work.

The goal is a multiplayer mod. I added this script component https://github.com/mwitz8/daggerfall-un ... Manager.csto the DaggerfallUnity prefab, which instantiates a NetworkManager prefab.

But it looks like the fact that your repo literally only has one file in it shows me that my entire approach to modding Daggerfall has been wrong. I've tried following tutorials, but how to get started is still a black box to me. I don't understand how you instantiated your BLBClassicFog prefab based on your code -- don't you need to instantiate through the DaggerfallUnity prefab? Maybe I would be able to understand it if you could point me to an up-to-date tutorial on how to get started, I would get an understanding of these basics that I'm clearly missing. For example, your lines

Code: Select all

using DaggerfallConnect;
using DaggerfallWorkshop.Game;
using DaggerfallWorkshop.Game.Utility.ModSupport;   //required for modding features
are completely foreign to me.

User avatar
BadLuckBurt
Posts: 948
Joined: Sun Nov 05, 2017 8:30 pm

Re: Prefab not instantiating

Post by BadLuckBurt »

I'm going to respectfully bow out, a multiplayer mod is way beyond what knowledge I can provide. The example I posted is just for a simple mod, making a multiplayer environment is a different beast and you'll definitely need a fork for that, not a mod.

Just out of curiosity, how much experience do you have with Unity and networking?
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

.

mwitz
Posts: 9
Joined: Mon May 30, 2022 8:17 am

Re: Prefab not instantiating

Post by mwitz »

I have some experience with Unity and networking separately, but I've definitely never done something so large scale. It's going to be interesting to put the two together.

Magicono helped me figure out what was going wrong. It looks like I was following some out-of-date tutorials on setting up and building mods. I might put what Magicono helped me do in the tutorials thread soon to help some other new Daggerfall modders out.

User avatar
BadLuckBurt
Posts: 948
Joined: Sun Nov 05, 2017 8:30 pm

Re: Prefab not instantiating

Post by BadLuckBurt »

mwitz wrote: Tue May 31, 2022 5:22 am I have some experience with Unity and networking separately, but I've definitely never done something so large scale. It's going to be interesting to put the two together.

Magicono helped me figure out what was going wrong. It looks like I was following some out-of-date tutorials on setting up and building mods. I might put what Magicono helped me do in the tutorials thread soon to help some other new Daggerfall modders out.
Glad to hear he got you sorted. I'm not sure how much the modding system itself would help with setting up multiplayer but you're probably a better judge of that than I am. I wish you the best of luck on this, it's a topic that always comes back up but so far no-one stepped up to give it a shot.
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

.

User avatar
Arneb
Posts: 166
Joined: Sun Mar 08, 2020 9:38 pm

Re: Prefab not instantiating

Post by Arneb »

Well, someone actually did:
viewtopic.php?t=4479
…but never came back to tell the story 😱

Post Reply