Skip to content

Getting Started

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

This Getting Started guide will step you through getting GMAS installed and building a basic Jump and Sprint ability, entirely in blueprint. It will rip out the existing Jump and Sprint in the GMC and replace them with abilities!

Here's a video of what it will look like at the end:
https://youtu.be/TNBCL5saAW0

Requirements

  1. Unreal 5.3+ (Possibly 5.2)
  2. GMCv2
  3. * GMC Demo Project (Obtainable From Discord, Preferably Version 7b)
  4. GMC Ability System

* Only needed if you want to follow this entire guide. Not necessary for standard usage.

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 for now.

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, in the CharacterBP, 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!

Second Ability: Sprint

Time to add a slightly more complex ability: Sprinting. First, add the following two GameplayTags to the project:

Ability.Sprint
Attribute.MoveSpeed

Modify the Attributes Data Asset to include the new MoveSpeed Attribute and give it a value of 800:

Now we need to configure our Movement Component to use the new MoveSpeed Attribute. Open up the MovementComponentBP and add a new node for "Event Movement Update". Similar to normal GMC usage, we're going to set the MaxDesiredSpeed, but we're going to get the MoveSpeed Attribute value from our ability system component:

Next, create a new GMCAbilityEffect named "SprintSpeedBuff". Configure it like so:

Ensure that "Negate Effect At End" is checked and "IsInstant" is not checked.

Now make a GMCAbility named "Sprint". In it, add a call to "Apply Ability Effect" where the SprintSpeedBuff Effect is applied to the ability owner's Ability Component. Then use an AbilityTask to wait until the input key is released and then end the ability. Finally, add an event node for "Event End Ability" that gets called when an ability ends. In this event, remove the SprintSpeedBuff Effect that was added.

Now to tie this ability into the Ability System Component. Back on the CharacterBP, select the Ability Component and add the Ability.Sprint tag to "Starting Abilities", and a mapping between the tag and ability into the "AbilityMap".

Then hook up the "IA_TPSprint" Started Event to Activate the ability. Make sure to connect the "Input Action" pin from the Event to the Ability, it's used for the "Wait For Input Key Release" task.

Hit Play, and you should be able to sprint with Left Shift! Check the debug info (single quote) to see the attributes change and the effects get applied.

Clone this wiki locally