Tip:
Highlight text to annotate it
X
Path data in Kynapse defines where a bot can or can’t go.
Without it, Kynapse cannot function properly.
In this movie, we’ll look at how to create pathdata in the Kynapse Unreal integration.
For more information about the Kynapse – Unreal integration process,
refer to the Kynapse – Unreal integration movie, or Unreal integration documentation.
The process of Path Data Generation creates a virtual map
of the navigable areas of your environment from a character’s point of view.
The first thing our Unreal level will need is an associated Kynapse world.
Each Kynapse world is a separate self-contained model of the game world
in which your characters perceive, decide, and act.
Open the Content Browser.
We could create a new world from scratch, by clicking the New button and using the Kynapse World Factory.
But Kynapse also comes with a DefaultWorld that is pre-setup ideally for human characters.
Let’s create our world by copying that.
Right-click the DefaultWorld and select “Create a Copy”.
Name the world “ExampleWorld” and put it into the "PDGExample package",
with the rest of the scene's assets.
Now select View > World Properties, in the Unreal Editor.
In the Kynapse section, replace the DefaultWorld object with the ExampleWorld you just created.
Now that we have a Kynapse world for our level, let’s create a new path data family.
A path data family is a set of all bots that see the navigable world the same way.
For example, a family of land-based bots might only see land as navigable,
while a family of aquatic bots might only see water as navigable.
Let’s create a new family by clicking the New button in the Content Browser.
Select "Kynapse PathData Family" from the list of factories.
Name the family “ExampleFamily” and set its package to "PDGExample".
Now double-click the ExampleFamily and set the Radius to 0.6,
Height to 2.0, and Step Max to 0.2, in the properties window.
This will mimic the size and abilities of a human.
The last thing we need is a PathData actor to maintain the NavMesh and graph,
that we'll generate for our Kynapse world.
In the Content Browser, go to the Actor Classes tab and drag a KynapsePathdata actor into the scene.
Double-click the actor icon to open its properties and add a new family by clicking the green + button.
Now add "ExampleFamily" to the actor.
If you decide to add additional Kynapse families to the scene later,
you must make sure to add them to this actor.
We’ll need make the world aware of this family as well.
Double-click ExampleWorld.
In the Pathdata Families section, add the ExampleFamily.
Now you’re ready to build the paths for your new family.
To generate path data in your Unreal Editor / Kynapse integration, click the Build Paths button.
Now to view the paths go to the Kynapse PathData option in the viewport dropdown
and select ExampleFamily.
Unreal Editor shows you the NavMesh and the graph.
The NavMesh, shown in blue, represents the total navigable area of the current pathdata family.
The graph, a series of points connected by lines, are the actual paths a bot would consider using
to navigate the NavMesh.
Now in order to test the path data, we’ll need to create a bot that actually uses it.
Open the Kismet Editor.
You’ll notice we have a standard “Level Loaded” and “Console Command” setup here.
There’s also a “Path Node” object for us to use as a spawn point.
We’ll spawn a bot exactly like we would in an ordinary Unreal workflow.
Create an Actor Factory, and have it spawn when “Loaded and Visible”,
and set the Factory’s “Spawn Point” to the existing PathNode_0.
Open the Actor Factory’s properties.
In the Factory settings, set the Factory to KynapseActorFactoryAI.
The Controller Class should already be set to KynapseAIController.
Now set the Pawn Class to KynapseExampleNPCPawn.
This identifies that the Factory will be using our Kynapse data and assign it our basic example pawn.
Finally, highlight the ExampleFamily in the Content Browser
and assign it to the Path Data Family of the Actor Factory.
Now the Factory is ready to use Kynapse data, we just need to assign it some sort of behavior.
Right-click the Kismet Editor and select New Action > AI.
Kismet displays a number of different off-the-shelf behaviors.
For now, let’s create a Wander agent.
Attach the "Finished" output of your Actor Factory to the "In" input of the Wander agent.
Now create a new Object variable to store the result of the Actor Factory
And connect that to the "Target" input of the Wander agent.
Now close the Kismet Editor and play the level.
As you can see, the bot wanders around the level just as we set.
Right now, our soldier has free reign over all the terrain.
What if we wanted to force him to use the bridge to cross the river, rather than allowing him to
walk over the water itself?
Also, why are we generating path data for areas he’ll never be able to reach,
like the ravine at the base of this waterfall or the rooftops of the castles?
In the next movie, we’ll address these concerns by customizing the pathdata generation process.