Interacting with smart objects
In this section, we will finalize the smart object system by creating an AI agent that will make good use of the previously created workbench Blueprint. As stated before, the AI agent will move around and shoot at random; from time to time, the gun will jam, and so the gunner will need to get to the workbench to fix it. The AI behavior will be handled by a behavior tree, and it will be quite straightforward, but it will help us understand how to interact with smart objects.
Let’s start by creating a helpful task we will be using in the behavior tree.
Creating the toss coin task
We are now going to create a task that will simulate the gun jamming. This task will be some sort of weighted coin toss and will return a bool
value – that is, a head or tails result. The weight of the toss will help us in defining how much the gun is prone to jamming. You should already be familiar with behavior tree tasks but, for a quick refresher, you...