Dungeon Tutorial and 1.0.1 Update

Daggerfall Tools for Unity 1.0.1 is now available for download. This version contains minor bug fixes and improvements to the weapon system.

The first tutorial is now also available. This introductory tutorial steps you through creating a new scene, importing a dungeon, setting up weapons, and more. You will find this and all future tutorials on the Tutorials menu page.

Please be sure to update to 1.0.1 before following the tutorial as it fixes a bug you will encounter otherwise.

Let me know what you think of the tutorial, especially if any parts are too hard to follow. I want the “Basics” series to be generally accessible and will revise if necessary to improve information presented.

Daggerfall Tools for Unity 1.0

Daggerfall Tools for Unity 1.0 is now available for general download. Click here for download page. Change notes are below.

I’ve been working on this like a man possessed the last week or so. I definitely need a short break to clear my head and get some perspective on what comes next. I’ll talk more about this when I can.

I hope you have fun with Daggerfall Tools for Unity! If you have any feedback, bug reports, or feature requests, please feel free to contact me.

v1.0.0

  • Exterior door triggers are now sized appropriately to doors.
  • Added support for exterior dungeon doors.
  • Added enum for static door types.
  • Added DaggerfallInterior component to layout interiors.
  • Hinged action doors are now loaded inside building interiors and dungeons. They can be locked, magically held, bashed open, opened by monsters, and play appropriate sounds.
  • Added example class to transition in and out of interiors.
  • Player controller can click into and out of building interiors using example script.
  • Player controller now has moving platform support and ceiling hit detection.
  • Fixed broken sky hemisphere swap, refined sky scrolling.
  • Sky component can now be attached anywhere, such as to an exterior parent object. It will search for MainCamera if one is not specified.
  • Added default unlit billboard shader to MaterialReader. This will be used by light billboards.
  • Added default unlit texture material to MaterialReader. This will be used by fireplaces and similar textures.
  • Added dungeon action records and examples of activation by player.
  • Add iTween to __ExternalAssets namespace for animating hinged doors and action records. iTween was chosen as it will be familiar to the most Unity developers.
  • Removed QuickSize() and QuickScale() from API as they were incompatible with standalone builds.
  • Added size and scale properties to new method GetCachedMaterial(). The cached method slightly reduces scene building time and is compatible with standalone builds.
  • Palette files can now be loaded in standalone builds.
  • Bug fixes to standalone build startup and loading from Resources.
  • Added exception handling when loading invalid enemy indices.
  • Added exception handling for missing Run and Jump inputs in player controller prefab.
  • Changed Scripts/Other folder to Scripts/Demo. Contents are now in DaggerfallWorkshop.Demo namespace. These classes are not part of core tools but show examples of specific tasks such as loading interiors.
  • Added example weapon loading with variable tinting based on metal type.
  • Added example attack manager for gesture-based attacks.
  • Fixed API bug when getting DFSize for animated weapon records.
  • Enemy mobiles now read in “not hostile” flag where set in game data, and will not attack unless provoked. Examples are guard in castles and liches/vampire the King of Worms court.
  • Added DaggerfallAudioSource component for dynamically loading and playing sound effects from DAGGER.SND.
  • Created sound enumeration to name and group effects.
  • Linked sound definitions to enemy mobiles and action triggers.
  • Added ambient effect player.
  • New flags to import sounds automatically.
  • Added flag to MaterialReader controlling mipmap creation.
  • Lots of fixes and extensions to Demo scripts.

Direnni Tower – Full Demo

I’m very close to Daggerfall Tools for Unity 1.0. To celebrate this upcoming milestone, I’ve created a new demo showing a bit of everything the toolset is capable of right now.

Direnni Demo

  • Explore remixed city environment during a late afternoon storm.
  • Enter any building or brave the depths of a transplanted Direnni Tower.
  • Fight dungeon inhabitants while dual-wielding heavy Daedric weapons.
  • Bash open randomly locked doors.
  • Full sound effects, played directly from Daggerfall’s effects file.

WebPlayer URL
http://www.dfworkshop.net/web_demos/direnni-demo/direnni-demo.html

Standalone Windows
www.dfworkshop.net/static_files/demos/DirenniDemoStandalone.zip

Controls

  • Alt+F4 to exit (standalone).
  • Click to capture mouse (webplayer).
  • ESC to uncapture mouse (webplayer).
  • Mouse move to look.
  • W, S, A, D to move.
  • SHIFT (hold) to run.
  • SPACE to jump.
  • LEFT-CLICK mouse to open doors, operate switches, etc.
  • Z to sheathe and draw your weapons.
  • RIGHT-CLICK and HOLD while moving mouse in different directions to attack enemies (Daggerfall style).
  • Attack locked doors with your weapons to bash them open (25% chance per hit to open).
  • P while in dungeon to recall back to entrance.

Sound Effects

After playing through the combat demo a few times, I felt a little sound would really liven things up. This turned into a bigger job than expected (doesn’t it always?) but I’m very happy with the result. This post talks about the new audio features in brief, and may be slightly technical if you’re not familiar with Unity.

So how does this work? To start with, let’s take a look at adding a sound manually. What you need to do is add the component DaggerfallAudioSource to any of your GameObjects. This scripts buddies up with Unity’s AudioSource component and feeds it sounds loaded dynamically from Daggerfall’s sound effects library.

Once the component is added, you set a preset (OnDemand, Looping, or None for no changes) and a Sound Index then click Apply(). This will load in the sound from Daggerfall as a regular AudioClip and apply it, along with your preset settings, to the Unity AudioSource. From there you just treat it as a normal audio source like any other and don’t have to worry about it any more. You can even preview sounds directly from the editor by index, id, or name.

Behind the scenes, things are a bit more complicated. As these audio clips are created dynamically they don’t have a matching file in the project hierarchy, and for some reason Unity doesn’t like to serialize procedural sound clips into the scene in the way it serializes stuff like mesh data. The other complication is that settings like “Play On Awake” don’t work as expected as the clip is not present in memory until after the component is running.

To handle all this, the DaggerfallAudioSource component will check to see if your AudioClip has been lost (from starting/stopping play, serialization/deserialization, recompile, etc.) then loads it back into memory again. It also handles booting the sound manually to simulate Play On Awake.

This is very lightweight and under normal play sessions the clip will only be loaded once at start. It’s only inside the editor where the clip may need to be loaded multiple times a session due to various reasons the editor dumps volatile data. It all just works as expected, even when using the little speaker to preview scene audio.

The other thing which caused some grief was actually converting the 8-bit PCM audio from Daggerfall into floats for AudioClip.SetData(). This needed special wrangling of the float values to convert bit depths properly, and the Unity docs weren’t much help here. A bit of Googling and face-desking saw me through to the end. Mostly, this was only hard because I can be an idiot sometimes.

On the support front, there’s a few other goodies coming with the sound update. I’ve created a SoundClips enum with about 80% of Daggerfall’s effects given a plain text, descriptive name. Where possible, I have grouped these by usage as I understand them. I also managed to work out how Daggerfall assigns sounds to enemies and action triggers, and put this into the toolset and API where appropriate. See below for updated DaggerfallAction editor window.

New DaggerfallAction Editor Window

The new number above is “Action Sound”. This is the sound ID to play when this action is triggered. I had to break out my hex editor again, as this action-sound mapping was previously unknown.

The next bit of support is you can import sound effects with dungeons, enemies, etc. Daggerfall Tools for Unity wires up all the audio sources for you to automatically bring your scenes to life. You can also create, change, and play sounds completely at run-time.

Last but not least, I’ve created a “spooky sound player” example component to randomly play those wonderful dungeon sounds (e.g wind blowing, doors opening, water dripping, etc.). This will later be joined by other example scripts as part of the tutorial series I’m working on.

I should have a new demo ready for you over the weekend with a full complement of sound effects to enjoy.

Privateer’s Hold Combat Demo

Below is a new standalone web build showing off many of the new features soon to be available in Daggerfall Tools for Unity 1.0.

Click the link below to explore Privateer’s Hold and vanquish foes with your trusty Ebony Dagger.

http://www.dfworkshop.net/web_demos/privateers-test2/privateers-test2.html

  • W, S, A, D to move.
  • Mouse move to look.
  • SHIFT to toggle run mode.
  • SPACE to jump.
  • LEFT-CLICK mouse to open doors, operate switches, etc.
  • RIGHT-CLICK and HOLD while moving mouse in different directions to attack enemies.
  • ESC to uncapture mouse.

Roadmap Update

I’m running behind on Release 3, however I’ve also managed to squeeze in features originally planned for 1.0 or later (such as weapon loading). My original plan was for Release 4 to be considered 1.0, but I’m so close to the finish line now that I’ve decided to push through and name the next release 1.0. This should be ready in another week or two, depending how much time I can allocate.

One feature that will be missing from 1.0 is improved content browsing directly from Unity’s editor. After reviewing what I want to achieve here and some limitations of editor scripts, I’ve decided to delay this feature to the post-1.0 pile. Creating a good user interface is always challenging, and there’s nothing functionally wrong with just typing in the name of the model/block/location you want to load. I will improve this, but I need to step back and clear my head before taking it on.

Once the 1.0 release is out, I’ll start work on a series of short YouTube tutorials to help newcomers with Daggerfall Tools for Unity. These will cover the basics of setting up a project all the way to creating a simple dungeon crawler with infinite levels. This will be a nice diversion and help me review the tools by actually putting them to work.

On a personal note, the development of these tools has been a lot of fun and I’ve not had to make the time sacrifices I made two years ago. I can get a lot done in an hour or two per day, plus a little extra on weekends, and I don’t need to miss out on any time with my family. Thanks to Unity doing most of the heavy lifting, I can take a new feature from concept to reality in very little time. <3 Unity.

Interiors Web Demo

I’ve uploaded a new web demo showing interior/exterior transitions of town buildings.

Wayrest Interiors
Controls: WSAD to move, SPACE to jump, SHIFT to toggle run, LEFTMOUSECLICK to activate doors, ESC to uncapture mouse.
www.dfworkshop.net/web_demos/wayrest-interiors-1a/wayrest-interiors-1a.html

I’m far from done with interiors, but the above demo is interesting in that all interiors are loaded procedurally. All interior models, layout data, and materials are converted in realtime from native binary data, right inside your web browser.

Essentially, Daggerfall’s world is being constructed from original binary data on another platform without emulation. The same could be done for an iOS or Android build, or any other platform supported by Unity. The total compressed build size is only 17MB.

Tools for Unity – Release 2

Daggerfall Tools for Unity Release 2 is now available. This version adds many new features, bug fixes, and small improvements over the initial version. The PDF Manual is also available.

Starting from this version, I no longer bundle Daggerfall Imaging and Daggerfall Modelling with the distribution. These tools are Windows-only and greatly increased the ZIP size. If anyone needs these tools, they’re available for download here as usual.

Patch notes for new version are below.

  • Added DaggerfallBillboardEditor script for additional billboard details.
  • Added enumerations for enemy mobile types in dungeons (e.g. GiantBat, SkeletalWarrior).
  • Added DungeonType enumeration to DFRegion (e.g. Crypt, Orc Stronghold, Vampire Haunt, etc.). Dungeon type is also displayed in Inspector when a dungeon is selected.
  • Added random encounter tables based on dungeon type.
  • Added animation support for atlased materials.
  • Added multi-facing enemy mobile billboard class.
  • Added enemy definitions for known enemy types.
  • Added animation groups for mobile units.
  • Added light import option for cities and dungeons.
  • Added enemy import options for dungeons.
  • Fixed minor RMB layout bug for non-combined city blocks.
  • Fixed minor billboard layout bug for city blocks.
  • Fixed minor ground plane tiling bug.
  • Fixed dungeon layout bug where RDB block positions on Z axis were reversed.
  • Fixed serialization bugs where native data is concerned. Unity does not like to serialize unsigned values. Opted to create Unity-compatible structures where needed rather than modify Daggerfall-native API structures. Removed [Serializable] flag from any API structs.
  • Moved MaterialReader and MeshReader to MonoBehaviour components on DaggerfallUnity singleton.
  • Moved material and mesh import options to their respective reader component.
  • Moved all mesh loading to MeshReader and removed ModelFile class. This eliminated some double-handling of data and slightly increased import times.
  • Added the ability to set preferred shader names on MaterialReader component. These are located using Shader.Find() during import.
  • Added the ability to set window modifier colours and brightness on MaterialReader
    component. This includes a custom window style option.
  • When loading Daggerfall files from API with the FileUsage.UseMemory option, FileProxy class will now look for a .bytes file of the same name in your Unity Resources folder (e.g. “arch3d.bsa.bytes”). This helps to create standalone builds (such as web builds) where the Arena2 folder is not required, or only partial Arena2 data is needed.
  • Limited full validation checks in DaggerfallUnity to editor mode. This allows builds with partial or no Arena2 data to launch correctly.
  • MeshReader, MaterialReader, and ContentLoader scripts are now set to FileUsage.UseMemory to support Resources file support as above.

Standalone Builds

One of the new features coming in Daggerfall Tools for Unity Release 2 is support for standalone builds where the Arena2 folder is not generally available. For example, the web builds I showed earlier would be considered standalone.

The toolset makes this possible using two complementary approaches. The first is just normal serialization of scene data. This is automatic and doesn’t require any work on your part. All of the materials and 3D models in your scene are just saved as you would expect, along with additional metadata about those resources. For example, every 3D mesh saves a list of default texture keys used to rebuild textures for climate swaps. You generally don’t need to think about this, it just works.

The second method is new to Release 2. When loading a file from Arena2 with FileUsage.UseMemory enabled (now the default), DaggerfallUnity will first try to use Resources.Load() to find that file from your Resources folder. This means you can add, for example, ARCH3D.BSA, BLOCKS.BSA, MAPS.BSA, and TEXTURE files to your Resources folder and load content in at runtime without the end user requiring a Daggerfall installation for your build. All you need to do is append “.bytes” to the end of any Arena2 files added to your Resources folder so Unity can load them as proper binary files. This works for every Arena2 file loaded through the API with FileUsage.UseMemory specified.

As an example of this, check out the new web player demo below. This loads a Wayrest city scene using normal serialized data for all of the models and materials. The sky however is created at runtime from SKY13.DAT in Resources. The entire build is 3.7MB (not counting the web player itself).

Wayrest Snow Scene (Point Filtering)
Controls: WSAD to move, SPACE to jump, SHIFT to toggle run, and ESC to uncapture mouse.
www.dfworkshop.net/web_demos/wayrest-snow-test1/wayrest-snow-test1.html

This freedom creates exciting opportunities for building Daggerfall projects directly for web or mobile platforms. You’re no longer limited by where Daggerfall can be installed. It’s all just binary data that Unity can use anywhere. I hope this freedom will inspire others to create amazing Daggerfall projects in the future.

Web Demo Test

I’ve uploaded a few simple Unity Web Player demos for my own test purposes. If anyone is interested, you can access them from the URLs below.

Controls are WSAD to move, mouse to look, Shift to toggle run, Space to jump, ESC to uncapture mouse.

If you have trouble launching the web player in Internet Explorer, try Chrome and see if that works.

Exterior (Daggerfall City)
http://www.dfworkshop.net/web_demos/daggerfallcity-test1/daggerfallcity-test1.html

Exterior (Daggerfall City, point filtering)
http://www.dfworkshop.net/web_demos/daggerfallcity-test2/daggerfallcity-test2.html

Dungeon (Privateer’s Hold)
http://www.dfworkshop.net/web_demos/privateers-test1/privateers-test1.html

This is a work-in-progress build, so don’t expect too much awesome just yet. These demos are mainly interesting in that I put them both together from an empty scene and uploaded in less than 10 minutes.

One more thing. I’ve disabled doors in the Privateer’s Hold test, as interacting with moving objects is still being written. You can get to the exit room without riding the throne up. See if you can remember how. ;)