Replicating Skyrim's Radiant AI in Unity (Dev Log)

Saturday, January 14, 2023

This blog post is just a summary of the full video I made on the subject.

You can watch it here:


Recently, I purchased Skyrim VR and as I was playing it, I started to wonder if the AI actually works. After investigating the modding tools, I discovered the "Sandbox" behaviour, a generic way of having AI handle their daily routines. After reading the documentation and parameters, I thought I could replicate this behaviour in Unity.

The Creation Kit documentation provides detailed information about the Sandboxing procedure, though it does not include actual code or behaviour. From the parameters provided, I was able to make an educated guess about how it works. My replication of the Sandbox behaviour is a bit simpler than Skyrim's as their behaviour includes full, automatic routines, while my setup has the routines split into different packages.

In this article, I'll be discussing some of the parameters used in the Sandboxing procedure. For example, the "Location" parameter specifies the area the AI will use the Sandbox behaviour in. The "AllowIdleMarkers" parameter shows that the AI can go and sit down, use anvils, etc. The "Energy" parameter determines the amount of time an AI can do the Sandbox behaviour, while the "MinWanderDistance" parameter determines how far the AI can wander while using the Sandbox behaviour.

In a previous video, I went over how the AI package system works and how the AI determines what to interact with. With the standardized Sandbox behaviour, I was able to improve performance for the AI. The detection check only runs when it's necessary, which is a significant improvement from previously having each idle behaviour as its own package.

To see the AI Sandbox behaviour in action, I'll use a character named Eadred as an example. Given his starting position, he will only find two interaction points - his bed and a chair. By stepping through the code, you can see how the AI interacts with these objects.

In the future, I plan to add modding support to my project, Sundermead, and potentially create a UI for the behaviour. If you're interested in playing Sundermead, you can wishlist it on Steam or follow me on Twitter and Discord for updates.