1. State Trees as a Flexible Alternative to Unreal Engine's Gameplay Ability System [0]

thumbnail State Trees can be used as a simpler and more flexible system for managing character skills compared to Unreal Engine's built-in Gameplay Ability System (GAS).

1.1. The Limitations of the Gameplay Ability System [1]

  1. The speaker finds Unreal Engine's Gameplay Ability System (GAS) to be a "bloated mess" and prefers to build ability systems from scratch for specific projects. [1]
  2. This preference stems from a dislike for using the existing GAS, leading to the exploration of alternative methods. [2]

1.2. Introducing State Trees for Gameplay Abilities [4]

  1. The speaker has developed a system using pure State Trees and gameplay tags that is very simple and can be used by others. [5]
  2. This system is demonstrated using jumping as an example skill, as it requires no additional assets and illustrates core concepts. [7]
  3. The basic premise is that while one skill is active, other skills should not be triggered, though this can be customized. [9]
  4. The project used for this demonstration was previously set up for showcasing State Trees for AI. [10]
  5. The standard jump input in Unreal Engine, which handles jumping and stopping, is shown as a baseline. [11]
  6. This basic system lacks the flexibility to implement custom hit events or different behaviors based on the character's state, such as during a jump. [13]
  7. While custom logic can be added in the Event Graph, it is suggested that this might not be the best approach for managing complex skill systems. [15]
  8. The speaker created a new State Tree named "Better Gas" (a simple, functional system) and two custom State Tree Tasks based on a blueprint base. [18]

2. Implementing a Jump Skill with State Trees and Gameplay Tags [20]

thumbnail

2.1. Custom State Tree Tasks for Skills [20]

  1. A skill neutral task was created as an empty placeholder. [21]
  2. A skill jump task was developed with specific logic for the jump action. [24]
    1. On Enter State: An event is triggered, and the state returns "Running" to keep the state active. [25]
    2. Event Graph (On Jumping State):
      1. An event is bound to On Character Landed to exit the jumping state. [26]
      2. The character is launched with a velocity of 1500. [28]
      3. Animations for jumping are handled by the Animation Blueprint (ABP), so no montage is needed for this basic jump. [28]
    3. On Character Landed:
      1. The state returns "Succeeded," indicating completion. [30]
      2. A gameplay tag is removed. [30]
    4. On Exit State:
      1. The On Character Landed event must be unbound to prevent it from triggering when the state is no longer active. [31]
      2. Gameplay tags are removed. [33]

2.2. Managing Skills with Gameplay Tags [34]

  1. Gameplay tags are used to trigger and manage skills. [34]
  2. A function is created to trigger a skill by adding a specific tag to a Gameplay Tag Container. [37]
  3. The system checks if the container already has a parent tag (e.g., "Skill") before triggering a new skill. [38]
    1. This prevents multiple skills from being active simultaneously. [38]
    2. Gameplay Tags Setup: Tags need to be enabled in plugins and defined in Project Settings, allowing for hierarchical structures (e.g., "Skill" with a child "Jump"). [39]
  4. If no parent skill tag is present, the new skill tag is added to the container, and a State Tree Event is sent to the State Tree. [45]
  5. The State Tree itself has a Root leading to a "neutral" state and a "jumping" state. [47]
    1. The "jumping" state uses the skill jump task. [47]
    2. A transition from "jumping" back to "neutral" occurs when the state is completed (returns "Succeeded"). [51]
    3. A transition from "neutral" to "jumping" is triggered by the skill jump event. [52]
    4. This transition logic checks if the active state has a transition for the received tag. [52]
  6. The Context Actor Class is set to "Third Person Character" to allow the State Tree task to access and manipulate gameplay tags on the character. [53]
  7. This setup allows for basic movement, jumping, and re-jumping after landing. [56]

3. Implementing State-Specific Hit Events [58]

thumbnail

3.1. Handling Hit Events in Different States [58]

  1. The system allows for different hit events to be triggered depending on the character's current state. [58]
  2. Traditionally, hit events like On Point Damage are handled in the character's Event Graph. [59]
  3. This can be modified to trigger specific logic within a State Tree state. [63]
  4. For example, On Neutral Entered, a Point Damage event can be bound to the character. [64]
    1. This means that when the character takes damage while in the neutral state, the bound event is triggered. [70]
    2. The logic for handling the damage can then be implemented within this state. [70]
  5. On Exit State, the Point Damage event must be unbound to prevent it from firing when the state is inactive. [70]
  6. In this example, the character has a point damage handler when neutral but not when jumping, demonstrating state-specific behavior. [72]
  7. This showcases how State Trees can manage distinct reactions to events based on the character's current gameplay state. [74]