Adding Wander
Here, we will define three states of AI. This will make it easier when specifying actions in different states. Now, the first state we will add is Wander. It will make the AI move randomly and indefinitely. This will be the initial state of the AI, and it will be capable of transitioning into other states once we approach the AI. The other two states are the two reactions that we give the AI. The idea is that when we approach the AI, there is a chance that it will flee or attack. The chance is the probability that we determined and created in the blueprint.
Setting up the project
Let's open Unreal Engine 4! Perform the following steps:
- First, we have to change our Enemy to act as a wandering frightened monster. So, double-click on the Enemy AIController. Now, navigate to Event Graph and zoom in.
- We want to create a new variable for State and make this Integer.
- Next, we have to change the Find Hero script. We will adapt this to detect the Hero. What we also want to keep is...