-
Notifications
You must be signed in to change notification settings - Fork 21
Create Tutorial Game Assets
The following section describes the game assets used throughout the tutorial. Further on are instructions on how to setup each of the defined objects in Blueprints. Blueprints is chosen so that these instructions are compatible across all project types.
The following game assets will be created to support the new RPAI system created.
- Tutorial AI Controller
- Tutorial AI Character
- Strength Restore Damage Type
- Energy Restore Damage Type
All of these resources will be created in Blueprints.
This is the primary AI Controller used to control the AI Character.
In your project, create a new Blueprint class from the base Character class. Name it "TutorialAIController".
Open your new AIController and add an RpaiComposerBrain
Component. This will now be the default brain component for your AI controller.
Because there is now a Brain Component type on this AI controller, Behavior Trees will no longer work with any AI using this Controller!
This is the base character used as an agent within the game world. It will perform actions and interact with the game world. It will have two attributes used within the game: energy and strength.
In your project, create a new Blueprint class from the base Character class. Name it "TutorialAICharacter".
Open the new TutorialAICharacter and add two (2) new variables. Each of the variables will be of type float and named Strength
and Energy
respectively. Set the default values for each of these new variables to 100.0.
Select the Mesh
component. Set the Anim Class
property to whatever value works for your project. For the purpose of the tutorial we will use Starter Content packages. Use the ABP_Quinn value.
For Skeletal Mesh Asset
select whatever value works for your project. For the purpose of the tutorial we will use Start Content packages. Use the SKM_Quinn option.
Most likely you will set the Mesh
component Location::Z
component to -90.0 an the Rotation::Z
component to -90.0 to align with the root component properly.
In the details panel, replace the AI Controller Class
class with TutorialAIController
Now add some functionality related to the Tutorial "Game" logic. Such as environment awareness, strength decay, and resting.
First update the properties that will store the data. Try to match the images below.
Add the environment awareness to the "Begin Play" event.
For a full game, it is advised to use a system such as EQS for environment awareness. The below is just a simple example for Tutorial purposes only.
Add the logic to decrease strength as time passes and increase energy a little bit as time passes in the "Tick" event.
This is used as an "Inverse" damage type for some game logic. This is used to adapt a Pain Causing Volume to a "Healing" Volume. It is specific to restoring the strength attribute of a game character.
Create a new Blueprint Class with a parent class of DamageType
. Name it "Strength Restore Damage Type"
This is used as an "Inverse" damage type for some game logic. This is used to adapt a Pain Causing Volume to a "Healing" Volume. It is specific to restoring the rest attribute of a game character.
Create a new Blueprint Class with a parent class of DamageType
. Name it "Energy Restore Damage Type"
All of the core Tutorials will use built in interaction systems. The Damage Types were defined so they can be assigned to Pain Causing Volumes. Then the Character will handle the damage differently. The rest of the logic is defined in the TutorialAICharacter
Blueprint.
Open the TutorialAICharacter
Blueprint you created earlier.
Select the Override option in the Functions section of the My Blueprint Panel. Override the Any Damage function. This will appear as a new event on the Event Graph. Configure as seen in the picture below:
This will cause the damage type to dictate how the damage is applied to the character. In this instance, the different damage types are applied to the Blueprint variables.
If you followed along with the tutorials specifically, you ought to have a ThirdPersonMap level. Open that level. If using a different project or template, open the world you would like to test the AI within.
Add two Pain Causing Volumes within the world. Place them anywhere the AI can navigate and a reasonable distance from each other. Using the values within the tutorial it would be best to set the volumes about 900.0 units apart.
Rename the first pain volume Energy Restore Volume. Set the Damage Type
to EnergyRestoreDamageType. Set Damage Per Sec
to 2.0 and Entry Pain
to false (unchecked).
Rename the first pain volume Strength Restore Volume. Set the Damage Type
to StrengthRestoreDamageType. Set Damage Per Sec
to 2.0 and Entry Pain
to false (unchecked).
Place an instance of the TutorialAICharacter within the level. Ensure the character is at least 900 units away from each of the newly added volumes.