Reacting to the Player: Character Events
Tutorial intermediate compiles

Reacting to the Player: Character Events

Updated intermediate Scene Graph Characters Code verified

Reacting to the Player: Character Events

So far we've read a character (Part 1) and pushed one (Part 2). This lesson flips the direction: instead of reaching out to the character, we let the character tell us when something happens.

A fort_character is a little broadcaster. Every time the player jumps, crouches, sprints, or gets eliminated, the character fires an event. Subscribe to it and you can react — a sound on jump, a score on sprint, a respawn on elimination — no trigger volumes required. We'll build a "hops counter": a point every time a player jumps.

The hops-counter scene: a scoreboard beside the castle arena, tracking every jump

The events a character broadcasts

<!-- section-art:the-events-a-character-broadcasts --> Reacting to the Player: Character Events: The events a character broadcasts

Character Event Runes

These are listenables on fort_character — call them to get the event, then Subscribe a handler:

Event Fires when… Payload
JumpedEvent() the character jumps the fort_character that jumped
CrouchedEvent() crouch state changes tuple(fort_character, logic) — who, and now-crouching?
SprintedEvent() sprint state changes tuple(fort_character, logic) — who, and now-sprinting?
EliminatedEvent() the character is eliminated an elimination_result

The pattern is always the same: Body.SomeEvent().Subscribe(handler). Notice the () after the event name — these are functions returning a listenable, so you call them, then subscribe to the result.

Subscribe vs. the loop you used for triggers

If you've wired triggers, you may have awaited an event in a loop. For character events, Subscribe is the cleaner fit: it registers a handler that runs every time the event fires, and returns immediately — no loop, no waiting.

# Register once; OnJumped runs on every jump, forever.
Body.JumpedEvent().Subscribe(OnJumped)

The handler receives the event's payload. For JumpedEvent, that payload is the fort_character that jumped — so one handler serves every player, and it always knows who hopped.

The handler: from body back to agent

The jump handler gets a fort_character. But score, team, and most device APIs want an agent, not a character. The bridge back is GetAgent[] — failable, so guard it:

OnJumped(Jumper : fort_character) : void =
    # Bridge body -> agent so we can talk to the score device.
    if (Who := Jumper.GetAgent[]):
        HopScore.Activate(Who)
        Print("A player hopped — point awarded")

GetAgent[] is the mirror image of Part 1's GetFortCharacter[]: one goes player→body, the other goes body→agent. You'll hop between them constantly.

Hooking up players — including latecomers

There's one subtlety. You subscribe to a character's events, but a player who joins after OnBegin won't have been hooked up. The fix: wire the current players now, and subscribe to the playspace's PlayerAddedEvent so newcomers get wired too.

Playspace := GetPlayspace()
for (P : Playspace.GetPlayers()):
    HookUp(P)                                  # everyone here now
Playspace.PlayerAddedEvent().Subscribe(HookUp) # everyone who joins later

The full hops-counter device

<!-- section-art:the-full-hops-counter-device --> Reacting to the Player: Character Events: The full hops-counter device

Invisible Hop Counter

This device is compile-verified in UEFN 5.8 (0 errors). Grab 03-device.verse, drop a Score Manager in your level, and drag it into HopScore. Press play and jump — your score ticks up, with no trigger pad anywhere.

Recap

  • A fort_character broadcasts: JumpedEvent(), CrouchedEvent(), SprintedEvent(), EliminatedEvent().
  • The pattern is Body.SomeEvent().Subscribe(handler) — call the event (it returns a listenable), then subscribe. Subscribe runs the handler every time, no loop.
  • JumpedEvent's payload is the fort_character that jumped, so one handler serves all players and always knows who.
  • Bridge body→agent with GetAgent[] (failable) when an API wants an agent — the mirror of GetFortCharacter[].
  • Hook current players in OnBegin and subscribe PlayerAddedEvent so latecomers are wired too.

Next — Part 4: The Bounce Arena — the capstone ties find + move + react into one playable minigame.

Get the complete code — free

You've read the full walkthrough. The complete, copy-paste-ready Verse solution is free for members — sign in to unlock it.

Free with your BrainDead.TV / BrainDeadGuild Discord account. The walkthrough above is always free.

Verse source files

Check your understanding

Test yourself with an interactive quiz and track your progress + earn XP — free for members.

Up next · Scene Graph: Characters Capstone: The Bounce Arena Continue →

Turn this into a guided course

Add UEFN Verse characters — JumpedEvent, CrouchedEvent, SprintedEvent, EliminatedEvent, Subscribe, GetAgent, PlayerAddedEvent to your free study plan — we'll suggest related pages and stitch the lot into one compile-checked, self-guided lesson with worked examples and quizzes.

Original tutorial generated by Verse Island from the Verse/UEFN knowledge base, with references to the Epic Games sources above. Code is validated against the knowledge base.

Comments

    Sign in to vote, comment, or suggest an edit. Sign in