Skip to content
Tutorials Center
My learning

Topics

Lesson 18 of 38 ยท Blueprints

Blueprint Communication: Casting, Interfaces and Event Dispatchers

Learn how Blueprints talk to each other: direct references, casting, Blueprint Interfaces, Event Dispatchers, and when each is the right choice for clean game design.

A game is many actors working together: a player opens a door, a pickup raises the score, an enemy dies and the HUD updates. Each of those needs one Blueprint to talk to another. Unreal offers several ways, and choosing well keeps your project flexible and fast. This lesson covers the four main patterns and how to choose.

Unreal Engine cannot run on this page. The editor steps are described and the stand-ins model each pattern in Python.

1. Direct reference

If you hold a variable of type BP_Door that points at a door, you can call its functions and read its variables directly. You get that reference by:

  • making the variable Instance Editable and picking the door in the level's Details panel;
  • saving the result of Spawn Actor from Class;
  • getting it from an overlap or trace event, or from Get All Actors Of Class.

This is the simplest and fastest approach, but the two Blueprints become tightly coupled: the caller must know the other's class.

2. Casting

Events such as overlap give you a generic Actor (or Other Actor). To call a player-specific function you cast: Cast To BP_PlayerCharacter. If the object really is that class (or a child of it), the cast succeeds and you get a typed reference; otherwise the Cast Failed pin runs.

flowchart LR
  O["Overlap: Other Actor"] --> C{"Cast To BP_Player"}
  C -- "Success" --> A["AddScore(10)"]
  C -- "Failed" --> X["Ignore"]

A cast is a type check. Failure is normal, so use the failed path.

Cast carefully:

  • A cast in a Blueprint creates a hard reference to that class, so the target and all its assets load with this Blueprint. Hundreds of casts to big classes make loading and memory heavy. Cast to a small base class (for example your own BP_PlayerBase) instead of a heavy one.
  • Do not cast every frame in Tick; cache the result in a variable.
  • If many unrelated actors should react, use an interface instead of casting to each class.
Python Stand-in: casting with isinstance

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

3. Blueprint Interfaces

A Blueprint Interface is a list of function signatures with no code, such as Interact() or TakeHit(Damage). Any Blueprint can implement it (Class Settings > Interfaces > Add) and write what the function does for itself. The caller sends a message: the node Interact (Message) works on any Actor, and does nothing if the actor does not implement the interface.

So a player's "press E" logic does a line trace and sends Interact to the hit actor. Doors open, chests give loot, levers flip, without the player knowing any of those classes. This is loose coupling, and it is the standard way to build interaction.

Python Stand-in: an interface in Python

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Interfaces also work in C++ (UINTERFACE), so designers and programmers can share them.

4. Event Dispatchers

A Dispatcher reverses the direction. An actor broadcasts "something happened" and any number of listeners bind their own event to it. The sender does not know who listens.

  • Create one in My Blueprint > Event Dispatchers > +, add inputs if needed.
  • The owner calls Call Dispatcher when something occurs (the enemy dies).
  • A listener gets a reference to the owner, drags off it and uses Bind Event to Dispatcher, then connects its own custom event (the HUD refreshes, the door unlocks).
  • Unbind when the listener is destroyed to avoid dangling calls.
Python Stand-in: an event dispatcher

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Other ways to share data

  • Game Instance, Game Mode, Game State and Player State: well-known global-ish places to keep data, reachable with Get Game Mode / Get Game Instance plus a cast.
  • Blueprint Function Libraries: static helper functions anyone can call.
  • Subsystems (C++): engine-managed singletons for a world, a game instance or a local player.
  • Gameplay Message or a custom Event Bus subsystem: a central channel for decoupled messaging in big projects.

Choosing a pattern

Situation Use
A button opens one specific door you placed Direct reference
"Did the player touch me?" Cast to a small player base class
Player interacts with many kinds of things Interface
One thing happens and many things react (kill, score, door) Event Dispatcher
Needs data for the whole game Game Instance / subsystem

If you notice you are casting to many different classes just to call a similarly named function, you probably want an interface.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does a Cast node do?

    A cast tests the type; if it fails, the Cast Failed path runs.
  2. 2. Which pattern lets one actor message many unrelated actor types?

    Interfaces define a shared function that unrelated classes implement.
  3. 3. In an Event Dispatcher, who knows about the listeners?

    The sender calls the dispatcher; bound listeners react without the sender knowing them.
  4. 4. Why can too many casts hurt a project?

    A cast references the class, so its assets are loaded with the Blueprint.

Summary

  • Direct references are simple but tightly coupled; casts check types and should target small base classes.
  • Interfaces give loose coupling for interaction; Event Dispatchers broadcast to listeners.
  • Use Game Instance, subsystems or libraries for shared data.
  • Pick the pattern from the situation, not by habit.

Next: Enhanced Input and Player Control