How to Add Flying AI Agents to Any Game in Unreal Engine

Whether your game is set among the stars or in the depths of the ocean, sophisticated AI is crucial for creating expansive and dynamic three dimensional worlds. Kythera AI Flight Navigation powers creatures and vehicles that confidently fly and fight in open, three-dimensional environments, meaning designers can effortlessly add agents that move skillfully through complex environments and around dynamic obstacles to any game.

This guide will touch on some of the more technical details of Kythera AI Flight Navigation and the process of using the Kythera AI toolset in Unreal Engine to enhance your game with intelligent, responsive flying agents.

Want to see the toolset in action? View the explainer video below.

Creating AI Agents in an Open 3D Game World with Kythera AI

Kythera AI Flight Navigation adds powerful tools for creating and managing flying agents to Unreal Engine. Let’s take a look at the features of Kythera AI Flight Navigation and how to use the toolset to easily add responsive flying agents.

Octree Generation

When using Kythera AI Flight Navigation, the Octree is built into the Unreal Engine editor and is updated automatically as the level is modified and can be dynamically updated at run-time with the use of Kythera AI’s custom blueprint nodes. For example, an event might trigger the level geometry to be moved or destroyed, and that same event can trigger that part of the Octree to be regenerated at runtime, so that the agents smoothly navigate around the new geometry.

The resolution of the Octree affects the navigation of tight spaces. This resolution and the range of support for agent sizes can be fully configured.

The clip above shows a preview of the Octree seen using the Debug Draw tools. The cell size is being changed from 300 units to 200 units to demonstrate how the Octree’s resolution can be configured to your levels requirements.

Pathfinding

Kythera AI’s Flight Navigation pathfinding search system uses the A* algorithm, searching through the Octree to find paths suitable for the agents to pass through. The agent can be instructed to find a path to a target, a location or an actor, using a scripted command in the form of a custom blueprint node.

Setting up pathfinding is simple! First set up an empty blueprint actor with a Kythera tag and position the actor in the location you’d like the agent, in this case the ship, to pass through, then simply reference the actor in the level blueprint, connecting it to the target parameter inside the Kythera scripted command node.

Kythera AI Navigation Splines allow designers to have precise control over agent movement and flight. Designers can guide the agents through a desired path, and can specify speeds and orientation at every point of the Spline. This feature is designed so that using it is easy and intuitive for those with previous experience with the Unreal Engine Spline tool.

The Navigation Spline uses the agent's existing movement and physics, maintaining a consistent and realistic appearance in a realtime gameplay scenario.

There are two parts to this feature:

  • a design tool in the editor and
  • blueprint nodes for instructing the agent to follow the Spline and perform actions.
Quick Guide

Here’s how easy it is to set this up with Kythera AI.

In the blueprints editor, attach the Spline parameter of the fly Spline node to the actor reference of the Navigation Spline in the level. Set another ship actor in the same level as the reference for the pawn variable. Next, add a ‘Path To’ blueprint node to instruct the agent to first navigate to the Spline, before joining it.

Back in the Kythera toolbar, we then open up the Kythera inspector tool. The Inspector tool allows users to easily configure the debug draw mode, and display useful information on screen. The mode shown displays the speed per Spline point, giving an immediate overview of the speeds the agent will target, at any specific point on the spline.

The target speed values can be changed quickly and easily by selecting each point and setting the speed parameter in the details panel. These parameters respect the ship's moving capabilities, and if the value on a Spline point is set too high, the ship may not be able to reach the targeted speed due to physical limitations. Alternatively, the Spline speed can be set below the maximum moving capability of the ship, and the ship will slow down to the target speed. This helps to add to the consistency and realism of the agent movements in your game world.

Complex behavior can be set through conditions, so the agent might;

  • choose to join a patrol Spline as part of its idle behavior,
  • spot and target an enemy agent while continuing to follow the Spline, or
  • disconnect from the spline to chase and eliminate the target threat found

… all based on the conditions you choose to set!

Agent Orientation using Splines

Kythera AI Navigation Splines give developers the ability to visualize both the orientation and the position of the agent at any point along the spline’s path as a timeline - enabling careful planning and careful decision making when designing scenarios - saving time and frustration in the flight navigation development process.

Kythera AI Splines Showing Orientation

Editor view of the Navigation Spline, showing vehicle orientation at various points along the spline.

There are a number of useful editing mode options like the;

  • Ghost vehicle mode, which enables designers to visualize the orientation and speed in between control points.
  • The vehicle rotation mode, which enables designers to easily rotate the orientation for the agent to target when passing through a specific control point.

Once happy with the orientation achieved with these modes, designers can switch back to the standard mode to fine-tune the placement of the control points.

Formations

Kythera AI Flight Navigation makes it easy to create Flight Formations - groups of several agents that fly together in a fixed three dimensional structure. The group navigates the environment and avoids collision either by bypassing large obstacles as a single group, or by allowing the formation to break and flow around smaller objects.

The Inspector tool allows us to see the pre-built behavior tree that the agents follow. With one agent configured as the ‘Leader’ and the others as ‘Followers, this "FollowTheLeader" behavior tree will find the nearest specific Kythera tag called "Leader" and join the Formation at the Leader's position.

Flight Formations can be set up in three easy steps using the Kythera AI Inspector Tool:

  1. Select the agents you wish to be followers and specify the behavior “FollowTheLeader’ in the details panel of the Unreal Editor.
  2. Select the agent set as the Leader and select the "KytheraPawn" component in the components panel.
  3. Head back to the details panel and add the tag "Leader" to the leader agent. This will activate the conditions to be ‘True’ and the Followers will now fly in formation behind the leader.

When using Flight Formations, the ‘Followers’ will try to maintain their position relative to the Leader, subject to their own movement capabilities and constraints, and are able to use the Flight Avoidance Feature to avoid obstacles blocking the way while maintaining formation.

Why a Simple-to-use Flight Navigation System is so Important

Navigation is often something taken for granted in modern games, but expansive and dynamic worlds pose new challenges. Players expect characters to flawlessly find paths through complex and evolving environments while avoiding other entities. When navigation works seamlessly, players can focus on enjoying the gameplay; when it doesn't, it becomes glaringly obvious.

Kythera AI Flight Navigation is an essential feature that transforms rigid algorithmic paths into believable behaviors, even in dynamic and complex three-dimensional environments. Flight Navigation, like all Kythera AI features, empowers studios to deliver the complex and creative experiences players expect using intuitive tools that minimize development time and costs.

Reviews from Studios Just Like Yours

"We are very happy with the navigation, even though we have very complex environments and ships have a wide degree of freedom in movement, the AI has no problem understanding and navigating the environment. The AI movement eases in and out of turns and accelerations to navigate paths, creating smooth and realistic acceleration and deceleration curves."

Norbert Varga, Creative Director - Digital Arrow

Case Study: Aquanox Deep Descent Case Study: Aquanox Deep Descent