Modding Tutorials

Discuss modding questions and implementation details.
Post Reply
l3lessed
Posts: 1400
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Re: Modding Tutorials

Post by l3lessed »

Looking a little closer, this looks actually easy to change. Here is the specific line of code and attached object in the base script file.

Code: Select all

                    // Set base height from sprite
                    size = dfMobile.Summary.RecordSizes[0];
                    controller.height = size.y;
I think you should be able to something like this I think.

Code: Select all

CharacterController targetController = target.EntityBehaviour.GetComponent<CharacterController>();
targetController.height = ;//Whatever you want it to be for the target           
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: Modding Tutorials

Post by Hazelnut »

Thanks, that's interesting stuff. This is slightly different code, as it's not en enemy or mobile - just a static npc sprite. :)

I got it all working using scale, but still like confirmation that this is the best way to do it, rather than supply the height and width of the new sprite in pixels.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

l3lessed
Posts: 1400
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Re: Modding Tutorials

Post by l3lessed »

So, when I grabbed the staticNPC object, there notation clearly says that billboard height is separate from the staticnpc object.

Look at the DaggerfallInterior script file, you can see how they setup the billboard, and from here, I think we can see how to change height for a static billboard.

Code: Select all

                 
                 // Calculate position
                Vector3 billboardPosition = new Vector3(obj.XPos, -obj.YPos, obj.ZPos) * MeshReader.GlobalScale;

                // Import custom 3d gameobject instead of flat
                if (MeshReplacement.ImportCustomFlatGameobject(obj.TextureArchive, obj.TextureRecord, billboardPosition, node.transform) != null)
                    continue;

                // Spawn billboard gameobject
                GameObject go = GameObjectHelper.CreateDaggerfallBillboardGameObject(obj.TextureArchive, obj.TextureRecord, node.transform);

                // Set position
                DaggerfallBillboard dfBillboard = go.GetComponent<DaggerfallBillboard>();
                go.transform.position = billboardPosition;
                go.transform.position += new Vector3(0, dfBillboard.Summary.Size.y / 2, 0);
                
One issue I just found, if you try to grab the billboard object and force reset the size, it won't let you. It is protected to a get only object.
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

l3lessed
Posts: 1400
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Re: Modding Tutorials

Post by l3lessed »

I have some more complicated ideas about this, but I did find this little object helper I recommend trying before we go down setting up multiple objects and object properties to get the height replaced.

Code: Select all

TextureReplacement.SetBillboardScale(ArchiveInt, RecordInt, ResizedValue);
Here is the more complicated code within the Billboard base script file. If the above doesn't work, I would start digging into these areas.

Code: Select all

        /// <summary>
        /// Sets billboard material with a custom texture.
        /// </summary>
        /// <param name="texture">Texture2D to set on material.</param>
        /// <param name="size">Size of billboard quad in normal units (not Daggerfall units).</param>
        /// <returns>Material.</returns>
        public Material SetMaterial(Texture2D texture, Vector2 size, bool isLightArchive = false)
        {
            // Get DaggerfallUnity
            DaggerfallUnity dfUnity = DaggerfallUnity.Instance;
            if (!dfUnity.IsReady)
                return null;

            // Get references
            meshRenderer = GetComponent<MeshRenderer>();

            // Create material
            Material material = MaterialReader.CreateStandardMaterial(MaterialReader.CustomBlendMode.Cutout);
            material.mainTexture = texture;

            // Create mesh
            Mesh mesh = dfUnity.MeshReader.GetSimpleBillboardMesh(size);

            // Set summary
            summary.FlatType = FlatTypes.Decoration;
            summary.Size = size;

            // Assign mesh and material
            MeshFilter meshFilter = GetComponent<MeshFilter>();
            Mesh oldMesh = meshFilter.sharedMesh;
            if (mesh)
            {
                meshFilter.sharedMesh = mesh;
                meshRenderer.sharedMaterial = material;
            }
            if (oldMesh)
            {
                // The old mesh is no longer required
#if UNITY_EDITOR
                DestroyImmediate(oldMesh);
#else
                Destroy(oldMesh);
#endif
            }

            // General billboard shadows if enabled
            meshRenderer.shadowCastingMode = (DaggerfallUnity.Settings.GeneralBillboardShadows && !isLightArchive) ? ShadowCastingMode.TwoSided : ShadowCastingMode.Off;

            return material;
        }
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

User avatar
Levethian
Posts: 30
Joined: Sun Jul 15, 2018 9:21 pm
Contact:

Re: Modding Tutorials

Post by Levethian »

No worries at all! Thanks for your response.

I cloned Daggerfall Unity directly from Github into 2019.4.2f1 (the resulting GitHub folder amounts to about 670mb). Tried it again, but still appear to be lacking the DFU-tools toolbar. I'm missing something that's probably monumentally obvious to someone experienced, or in possession of a brain. Do these images look wrong?

Image
Image
TheLacus wrote: Fri Jul 17, 2020 4:33 pm
Levethian wrote: Mon Jul 06, 2020 9:01 pm Stuck in a similar place to septua77. I've cloned DFU from GitHub Desktop into Unity 2019.4.2f1, and downloaded the 'Daggerfall Tools for Unity' package, and opened DFU in Unity (7 compile errors upon loading, if that's worthy of note), and imported the tools package. Restarted & repeated, but the 'Daggerfall Tools' toolbar isn't showing yet. Not sure what I'm missing. Any advice very much appreciated.
Somehow missed this message, sorry for the delay. If you still face this issue, you need to open a clean download of Daggerfall Unity from Github; it includes most recent version of Daggerfall Tools for Unity so you don't need to download and import it separately. 2019.4.2f1 is now the right version of Unity to use.

User avatar
Jay_H
Posts: 4062
Joined: Tue Aug 25, 2015 1:54 am
Contact:

Re: Modding Tutorials

Post by Jay_H »

Levethian wrote: Wed Jul 22, 2020 12:04 amDo these images look wrong?
These images don't appear at all :lol:

User avatar
Levethian
Posts: 30
Joined: Sun Jul 15, 2018 9:21 pm
Contact:

Re: Modding Tutorials

Post by Levethian »

ohnu! I am truly definitely not a boomer honest really :mrgreen:
https://photos.app.goo.gl/p4rtYd1p6q4Y31aj6
https://photos.app.goo.gl/kshmyTJrYFXbacfWA
Jay_H wrote: Wed Jul 22, 2020 1:50 am
Levethian wrote: Wed Jul 22, 2020 12:04 amDo these images look wrong?
These images don't appear at all :lol:

User avatar
Ralzar
Posts: 2211
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Re: Modding Tutorials

Post by Ralzar »

Levethian wrote: Wed Jul 22, 2020 9:41 am ohnu! I am truly definitely not a boomer honest really :mrgreen:
https://photos.app.goo.gl/p4rtYd1p6q4Y31aj6
https://photos.app.goo.gl/kshmyTJrYFXbacfWA
Jay_H wrote: Wed Jul 22, 2020 1:50 am
Levethian wrote: Wed Jul 22, 2020 12:04 amDo these images look wrong?
These images don't appear at all :lol:
That error at the bottom of the second picture sure doesn't look right.

Either you didn't download the correct version of the DFU repo or you edited a file in a way you shouldn't have.

User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: Modding Tutorials

Post by Hazelnut »

More specifically you seem to have some code in Addons/IncreasedTerrainDistanceMod which is causing issues. Maybe get rid of this and get the environment working first.

Is this your mod code? It should be in Game/Mods not Addons. Also curious what you're trying to mod about terrain?
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
TheLacus
Posts: 1305
Joined: Wed Sep 14, 2016 6:22 pm

Re: Modding Tutorials

Post by TheLacus »

Hazelnut wrote: Mon Jul 20, 2020 9:27 pm I'm experimenting with replacing billboard textures and having some issues. I want to replace an NPC billboard sprite but I can't figure out how to set the new size / aspect ratio - it always seems to be based on the original texture record I am replacing causing the replacement to be stretched.

Do I need to figure out the scaling to convert original aspect ratio to new replacement... is there no other easy to do this like just provide the new size in pixels?
The rationale is that you can make an estimation of the final size by setting a scale if you are replacing classic texture with an high resolution alternative. I felt a size in pixels would be less intuitive in this situation.
I believe you are working with the same resolution as classic, which unfortunately doesn't benefit from that choice.

Data from xml files is retrieved with load order so I unsuggest to set size in any other way.

Post Reply