Skip to content

Create Tutorial Game Assets

◄hollsteinm► edited this page Mar 30, 2024 · 16 revisions

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.

Define Tutorial Game Assets

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.

Tutorial AI Controller

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.

CreateController_Edited

Because there is now a Brain Component type on this AI controller, Behavior Trees will no longer work with any AI using this Controller!

Tutorial AI Character

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".

CreateCharacter_Edited

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.

CreateCharacter_Variables_Edited

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.

CreateCharacter_Redux_Edited

In the details panel, replace the AI Controller Class class with TutorialAIController

TutorialEdits_CharacterRedux

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.

MOVEME_TutorialAICharacterMyBlueprint

MOVEME_TutorialAICharacterStrengthVolumeDetails

MOVEME_TutorialAICharacterEnergyVolumeDetails

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.

MOVEME_TutorialAICharacterBeginPlay

Add the logic to decrease strength as time passes and increase energy a little bit as time passes in the "Tick" event.

MOVEME_TutorialAICharacterTick

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 strength attribute of a game character.

Create a new Blueprint Class with a parent class of DamageType. Name it "Strength Restore Damage Type"

DamageType_Edited

Energy 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"

Interaction Logic

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.

Take Damage

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:

Character_TakeAnyDamage_Edited

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.

Level Setup

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.

Pain Causing Volume

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.

World_PainVolumes_Edited

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).

World_EnergyRestoreVolume_Edited

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).

World_StrengthRestoreVolume_Edited

AI Character

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.

World_AICharacter_Edited