Skip to content

Getting Started

Brandon Forbes edited this page Mar 7, 2024 · 19 revisions

This Getting Started guide will step you through getting GMAS installed and building some basic abilities.

Requirements

  1. Unreal 5.3+ (Possibly 5.2)
  2. GMCv2
  3. GMC Demo Project (Obtainable From Discord, Preferably Version 7b)
  4. GMAS (Git clone it into the Plugins directory)

At the time of writing, you must compile GMAS from source along side GMC. This is because GMAS includes a custom SyncType that must be built into GMC. This requires a minor edit to the GMCCore.

In GMCCore.Build.cs, inside the GMC Plugin, add the following two modules to the PublicDependencyModuleNames:

StructUtils
GMCAbilitySystemTypesInclude

If everything compiles and the editor launches, you should be good to go!

Hooking Up The Ability System Component (ASC)

For this guide, we will be using the BP_TPCharacter and BP_TPMovement blueprints located inside GMCv2 BaseCharacters Content. You can either use them directly, or make a copies. Make sure to update the BP_GameMode Default Pawn if you make a copy. These will be referred to as the CharacterBP and MovementComponentBP.

Begin by adding a GMC Ability System component to the CharacterBP.

Then, open up the MovementComponentBP. Quite a bit needs to be done here, as it's where we'll be wiring GMC into the ASC. The ASC has matching functions for the relevant GMC Events that need to be connected.

Create a local variable of type GMCAbilitySystem component.

The only "complicated" one is Event Bind Replication Data:

The following Events just need to be hooked up to their matching ASC names:

Pre Local Move Execution
Gen Ancillary Tick
Gen Simulation Tick
Gen Prediction Tick

Make sure to connect all of the event variables to the parent and ASC function calls.

When it's done, it should look like:

All hooked up! Go ahead and close the movement component, we won't be using it anymore.

Gameplay Tags

GMAS uses GameplayTags extensively to function. You can add Tags however you want to the project, but for now make sure you have the following two tags (prefixes matter):

Ability.Jump
Attribute.Stamina

The most straight forward way to add Tags is to go Edit -> Project Settings -> GameplayTags -> Manage Gameplay Tags... and press the green plus. However you add them, it should look like this when you're done:

Attributes

Attributes are managed in GMAS via a DataAsset. This allows for defining Attributes purely in Blueprint, no C++ required!
Create a new DataAsset Blueprint of type GMCAttributes Data and name it "Attributes":

Open up the created DataAsset and add an element to the "AttributeData". Set the Tag to Attribute.Stamina, the default Value to 100, and keep GMCBound checked.

In the CharacterBP, select the attached Ability Component. In the Details pane, under "GMC Ability System Component", add an element to the Attributes property. Set its value to the created Data Table.

Hit Play in the Editor then tap the ' (single quote) button. A debug view should pop up that lists Stamina under your attributes.

First Ability: Jump

Create a new Blueprint of type GMCAbility and name it Jump:

Open it up, and you'll see an empty Event Graph. In the Details pane, set the Ability Tag to Ability.Jump. Ignore everything else in the Details pane for now.

In the event graph, add the Event Begin Ability node. This is triggered whenever an ability is activated, and is the main entry point to every ability. All this ability will do is add an Impulse in the Z direction to the MovementComponent. There is a helper method to get the movement component. Setup the ability to look like:

Make sure that VelChange is True and that the EndAbility node is called. Close the ability, it's done.

Now we need to hook the ability up to the ASC. Open up the CharacterBP, and select the attached GMC_AbilitySystem component. In the Details pane, under "GMC Ability System Component", the following needs to be set:

  • Add Ability.Jump to "Starting Abilities"
  • Add a new Element to the "Ability Map". Key: Ability.Jump, Value: Jump

Abilities can only be used if they have been granted to the ASC, either through effects or by setting them as Starting Abilities. The Ability Map is used to link tags to actual abilities on the component.

Finally, add an "ActivateAbility" call on the Ability System Component on the "IA_TPJump" input Started event. Set the Ability Tag to Ability.Jump.

If everything is set up correctly, you should now be able to jump using the spacebar! You'll be able to jump while in the air; we'll fix this later when we add a cost.

Adding An Ability Cost

Time to make the Jump cost some stamina! Similar to GAS, Ability Costs are done via Effects. An Effect is what is used to modify attributes. So we need to make an Effect that will subtract some stamina.

Create a new GMCAbilityEffect BP, name it JumpCost, and open it up:

Under the details pane, expand GMCAbility Effect -> Effect Data. Every property can be hovered for details about it. Uncheck "Negate Effect At End". Add an element to "Modifiers" at the bottom. Set the modifier's "AttributeTag" to be Attribute.Stamina, and the "Value" to be -5. The value is negative because we want to apply a -5 delta change to the stamina.

Open up the Jump ability again. Immediately after the "Begin Ability" node, add a "Commit Ability Cost" node. Also let's add a check to make sure we're on the ground by using the "IsMovingOnGround" check from our MovementComponent. Then, under the Class Defaults->Details, set the AbilityCost to our newly created JumpCost effect.

Compile and run the game. Press the ' (single quote) button to bring up the debug and start jumping. You should see Stamina go down by 5 every time you jump!

Clone this wiki locally