Why Boss Templates Matter
When you are building a Soulslike boss AI, starting from scratch every single time is a slow process that wastes weeks of iteration. Most people do not realize this until they have already built three unique bosses and spent more time on behavior scripting than on level design. A solid template structure lets you test new mechanics in hours rather than days. Here is how the system actually works under the hood. Every boss in Elden Ring runs off a state machine framework, and the best templates separate concerns into distinct layers: the input parser, the decision engine, and the animation controller. The input parser listens for player position, distance, and current action. The decision engine compares that data against weighted conditions. The animation layer handles playback and blend tree transitions. If you dump all of that into one script, you will regret it when a boss has six attack types and eight movement patterns. I learned that the hard way on a custom boss project where the initial implementation became an unmanageable tangle of if-else chains. After a week of debugging overlap issues between attack phases, I broke the system apart entirely and rebuilt it using a modular component setup. That cut my total boss build time from about two weeks down to roughly three or four days per boss.
The Core Template Structure
The template you should start with has four main files or modules. First is the boss base class, which handles health, invincibility frames, and phase transitions. Second is the behavior tree or state machine layer, which decides what action to take next. Third is the move set controller, which queues and blends animations. Fourth is the detection and targeting module, which calculates where the player is and updates aim direction. Keep these separate. I have seen too many people put targeting logic inside the animation controller and then spend four hours trying to figure out why their boss attacks through walls during a transition. The targeting module should feed data to the behavior tree, which sends commands to the move set controller. The boss base class should only handle lifecycle events like damage registration and phase switching.
Building the Detection System
Distance checks are the most important part of any boss template. The detection module needs to measure player distance, player angle relative to the boss facing direction, and whether the player is behind or in front. You can do this with simple dot products and vector math. The result tells your behavior tree whether the player is in range for a melee strike, a projectile, or a special phase move. Here is a counter-intuitive detail most beginners miss. You should not use a single flat distance threshold. Bosses in Elden Ring use layered detection zones with different radii for different actions. A grab attack might trigger at two meters, while a sweeping AOEs kicks in at four meters. If you use one radius, your boss will feel either too passive or too aggressive depending on which value you pick. Build multiple detection bands into the template and assign each boss action to its own band. I hit a specific edge case once where a boss kept triggering a back-step animation even though the player was clearly in front. The problem was that my detection angles were calculated using the boss world rotation instead of the facing direction after animation blends. Fixing it required extracting the actual facing vector from the animation root bone each frame rather than relying on transform.forward. That one change cleaned up half the weird behavior bugs I was chasing.
Get the Full Details

The Decision Engine
Most people use a behavior tree for this, and that is the right call. A behavior tree lets you compose complex boss logic from small reusable nodes. You will have nodes for checking conditions like player distance, player health percentage, boss phase, cooldown states, and random chance. Each node returns success, failure, or running. The tree walks through priority branches until it finds a matching action. The alternative is a state machine, and that works too for simpler bosses. State machines become unwieldy when you have more than five or six states with overlapping conditions. If your boss has a basic attack loop, a charge attack, a summon phase, and a desperation move, a state machine with cross-transitions is possible but painful to maintain. A behavior tree keeps the logic readable because each branch is self-contained. One thing to watch out for is action priority. Your template should have a guard rail that prevents low-priority actions from interrupting high-priority ones mid-execution. I once had a boss that would randomly cancel a dramatic finisher move because a low-tier detection tick fired while the animation was playing. That looked terrible and broke pacing completely. Add an action lock flag that only releases when the current move reaches a cleanup state.
Animation and Move Set Handling
The move set controller should not play animations directly from the behavior tree. Instead, the tree sends commands like play_attack_one or transition_to_phase_two, and the move set controller resolves those into animation events. This separation means you can swap animations without touching AI logic, which matters a lot when you are balancing or tweaking boss difficulty. Blend trees are essential for movement. A boss that snaps from standing to sprinting looks robotic. Set up a two-dimensional blend tree for movement speed and direction relative to the player. The template should expose parameters for blend speed and duration so you can tune each boss individually. Faster bosses get snappier blends. Heavier bosses get slower, more deliberate transitions. Attack animations need recovery frames. Every attack in a Soulslike has a windup, an active window, and a recovery period. Your template should tag these frames explicitly so the detection system knows when the boss can be interrupted. Without frame tags, you end up with bosses that are either completely vulnerable during attacks or completely unhittable during them. Both feel bad. Tagging frames gives you precise control over the risk reward window.
Phase Transition Logic
Phase changes are where most templates fall apart. The simplest approach is to check boss health percentage at the end of each action cycle, not during animations. If the health drops below the threshold, set a phase flag and trigger a transition sequence. The transition sequence should pause the behavior tree, play a cinematic or stance animation, reset certain cooldowns, and unlock new actions before resuming normal operation. Be careful with cooldown resets. If you reset all cooldowns on phase change, your boss can chain heavy abilities back to back and become unkillable in practice. Reset only the cooldowns that belong to the new phase, and leave existing ones intact unless the design specifically calls for a full reset. This keeps difficulty curves predictable. Another common mistake is forgetting to update detection radii during phase transitions. A phase two boss often has larger attack ranges. If your template locks detection values at initialization, the boss will underperform in later phases. Include a method in the template that re-evaluates all detection bands when the phase changes.

Implementation Notes and Pitfalls
If you are working in Unity with C#, I recommend a component-based architecture. Keep the boss base as a MonoBehaviour, the behavior tree as a separate class or component, and the move set as another component. Pass references through the inspector. This keeps dependencies clear and makes it easier to debug when something breaks. If you are working in Unreal Engine, the Behavior Tree and Blackboard system is built for this exact use case. Use a custom class for your boss base and attach a blackboard with shared variables like player reference, current phase, and health percentage. The blackboard approach scales well because multiple bosses can share the same behavior tree assets while keeping their own data separate. A practical bottleneck you will run into is animation event reliability. Animation events sometimes miss or fire late depending on your physics timestep and animation rate. The workaround is to run animation event checks on the animation update callback rather than the game update loop. This keeps event timing consistent regardless of frame rate fluctuations. I wasted a full day tracking down a bug that turned out to be exactly this issue.
What This Template Will Not Do
This template is not a plug-and-play solution for every boss type. It works best for humanoid or quadrupedal bosses with clear attack patterns and phase structures. Pure environmental bosses, multi-phase swarm encounters, or bosses that rely heavily on projectiles with complex trajectories may need additional subsystems layered on top. The core template handles the foundation, but you will still do custom work for edge cases. Also, this approach does not solve balancing for you. You will still need to tune damage values, animation timings, cooldown durations, and detection radii through playtesting. A good template makes iteration fast, but it does not replace the actual iteration. Budget at least a few days of testing per boss even with a solid template in place.
Where to Find the Elden Ring Boss Template Best Files
The community has shared several implementations across GitHub and Unity forums over the years. Look for repositories that include a behavior tree system, a move set controller with frame tagging, and detection bands separated by action type. Avoid templates that bundle everything into a single monolithic script. Those are harder to modify and usually contain unnecessary overhead that slows down iteration. Pick a lightweight foundation and add what you need.
