ATBTT - Event System

ATBTT - Event System

Introduction to the Event System

Overview of the Event System

  • The event system allows actors in a game to subscribe to events, enabling them to respond dynamically when those events are triggered.
  • This system facilitates complex interactions between various game elements, allowing for special abilities and effects based on events.
  • It promotes decoupled code architecture, reducing hard references among actors and preventing tangled dependencies.
  • The speaker has integrated this event system with a stat system, showcasing its practical application within their toolkit.

Practical Example Setup

  • A practical example will be demonstrated using blueprints to illustrate how the action system works with the event system.
  • The global dispatcher hub blueprint must be placed in the scene for the action system to function correctly.

Creating an Event Test Actor

Blueprint Creation

  • A new actor blueprint named "bp_event_test" is created to visually demonstrate changes when events occur.
  • A static mesh (sphere) is added to represent the actor visually during event triggers.

Binding Events

  • To listen for events, an interface (event holder blueprint interface) is added to the actor, allowing it to run specific events when triggered.
  • The actor binds itself to existing events from the toolkit, such as "unit selected," which will trigger visual changes.

Testing Event Functionality

Visual Feedback on Events

  • When a unit is selected in-game, the sphere's size increases by 50%, demonstrating that the event binding works effectively.

Debugging and Searching Events

  • If issues arise regarding where an event is called from, Unreal Engine provides a search feature (Ctrl + Shift + F), allowing users to locate blueprints associated with specific events.

Adding Custom Events

Creating New Gameplay Tags

  • Users can create custom gameplay tags for new events; these tags help organize and manage different types of game actions effectively.

Implementing New Events

  • An example of adding a new test event ("new_event_test") demonstrates how users can expand upon existing functionality within their projects.

Calling Events from Actors

Setting Up Input Actions

  • Another actor blueprint ("bp_event_caller_tests") is created that calls an event in response to player input (pressing 'X').

Subscribing Multiple Events

  • The ability exists for actors to bind multiple events simultaneously; however, this feature may require future updates for easier implementation.

Handling Different Event Responses

Distinguishing Between Events

  • Using a switch statement allows differentiation between responses based on which subscribed event was triggered.

Modifying Actor Behavior Based on Events

The tutorial emphasizes best practices by suggesting that visual changes should ideally be handled through actions rather than directly within logic code.

Utilizing Payload in Events

Passing Additional Data

  • The payload feature allows additional data or references (like target units in attack scenarios), enhancing flexibility during event handling.

Accessing Payload Information

  • When running an event, both calling objects and payload data can be accessed easily within your functions.

Global vs Local Dispatcher Hubs

Understanding Dispatcher Hubs

  • Individual dispatcher hubs can improve performance by limiting scope; they allow actors only interested in certain local events without interference from global ones.

Example Implementation

  • An example shows how unit stats call their own dispatcher hub while also interacting with global ones for broader functionality.

Debugging Tools for Event System

Utilizing Debug UI

  • A debug menu displays active subscriptions per actor and helps identify any issues related to unexpected behavior or bugs concerning event triggers.

Conclusion & Future Use Cases

  • The speaker encourages viewers with questions or confusion about implementing this system and hints at further tutorials utilizing this framework for more complex mechanics.

Turn any video into a summary like this

YouTube links, meetings, lectures. With transcripts, search, and chat.

Video description

In this tutorial I cover how to use the Event System for subscribing to and running gameplay events. Join the ATBTT Discord: https://discord.gg/pYvPwCG Support thread: https://forums.unrealengine.com/unreal-engine/marketplace/31005-support-advanced-turn-based-tile-toolkit?60108-Advanced-Turn-Based-Tile-Toolkit-Released-Large-Images= Available at the Unreal Engine Marketplace: https://www.unrealengine.com/marketplace/en-US/product/advanced-turn-based-tile-toolkit