Skip to content

Call a BPVerse actor override from C++ and call back into C++

Section titled “Call a BPVerse actor override from C++ and call back into C++”
  • Status: current.
  • Engine: ue6-main 61e2877e, Linux x86_64, Epic clang 23.1.5 (v27 SDK).
  • Context: Standalone UE6, BPVerse actor in project Content.
  • Prerequisites: A C++ runtime module loaded at Default, Solaris and Verse enabled, and verse.UObjectBinding=1 in [ConsoleVariables]. Headless placement uses PythonScriptPlugin and EditorScriptingUtilities. On this checkout, apply the reflection-types workaround before the dump.

Derive a Verse class from a native actor, dispatch a C++ event to the override, and observe a call back into C++. The reflection dump gives the names and argument types the Verse compiler expects. Here C++ APawn* becomes ?pawn and the native function library keeps the name CoopApi.

In the CoopZero module, give an AActor subclass named ACoopInteractable a Blueprint event. Use a standard reflected header with UCLASS(Blueprintable) and GENERATED_BODY(), and place the event in the public section.

UFUNCTION(BlueprintImplementableEvent, Category = "Coop Zero")
void Interact(APawn* Who);

Use a separate reflected UBlueprintFunctionLibrary subclass named UCoopApi with this public method. Define it in C++ and log the supplied string with UE_LOGF(LogCoopZero, Display, "%ls", *Message) or another observable implementation.

UFUNCTION(BlueprintCallable, Category = "Coop Zero")
static void CoopLog(const FString& Message);

Build the editor target. Put just the two imports below in a temporary .verse file under Content. With P and UE set to the project and engine roots, run the headless editor against an empty $P/Saved/reflection_exit.py. Use the build wrapper when required by the workspace.

Terminal window
timeout 180s "$UE/Engine/Binaries/Linux/UnrealEditor-Cmd" "$P/CoopZero.uproject" \
-run=PythonScript -Script="$P/Saved/reflection_exit.py" \
-nullrhi -unattended -nosplash -nosound -stdout \
'-ddc=(ProjectPak,EnginePak,Local)' -LocalDataCachePath="$P/DerivedDataCache" \
-ExecCmds="verse.reflection.Dump=Engine+CoopZero" \
-dpcvars=verse.reflection.Dump=Engine+CoopZero -abslog="$P/Saved/reflection-shim.log"

Read Saved/VerseProject/CoopZero/ScriptReflection/{CoopZero,Engine}.verse for the real signatures. The dump showed coop_interactable and coop_game_mode under /Script/CoopZero, with Interact<native><public>(Who:?(/Script/Engine:)pawn):void on coop_interactable. It also showed a CoopApi module with CoopLog<native><public>(Message:string):void.

Replace the temporary seed with Content/probe.verse.

using { /Script/CoopZero }
using { /Script/Engine }
probe := class(coop_interactable):
Interact<override>(Who:?pawn):void =
CoopApi.CoopLog("VERSE_INTERACT_OK")

Use LevelEditorSubsystem to create or load /Game/Maps/Slice and pass unreal.load_class(None, "/Game/_Verse.probe") to unreal.EditorLevelLibrary.spawn_actor_from_class. Save the level and dirty packages, then reload the map and confirm that it contains one probe. Set GameDefaultMap=/Game/Maps/Slice and GlobalDefaultGameMode=/Script/CoopZero.CoopGameMode under [/Script/EngineSettings.GameMapsSettings]. In the native GameMode’s BeginPlay, call Interact on the placed actor with the result of UGameplayStatics::GetPlayerPawn(this, 0).

The /Script imports activate BPVerse for the project Verse package and expose the loaded native module through reflection. The startup device-profile CVar makes the dump available during the Verse compile, and the dump captures the compiler-facing types, including option wrapping on the object pointer. The generated Blueprint event dispatch enters the Verse override on the placed subclass. Its call to CoopApi.CoopLog enters the reflected native static method, whose log confirms the round trip.

  • Evidence level: runs in packaged build (Linux Development, BuildCookRun). The packaged game’s Saved/run.log (lane step01c, re-run by the independent check) has LogCoopZero: Display: VERSE_INTERACT_OK once and no Verse or Script errors. Not yet: works in gameplay (no player input involved).
  • How: The reflection command above logged Dumped /Script/CoopZero: 2 types, 0 enums, 1 function libraries. Running UnrealEditor-Cmd "$P/CoopZero.uproject" -run=PythonScript -Script="$P/Scripts/place_probe.py" -nullrhi -unattended with the same DDC flags logged COOPZERO_PLACE_OK map=/Game/Maps/Slice class=/Game/_Verse.probe count=1 and the Verse compile reported finished: SUCCESS.. Running timeout 120s UnrealEditor-Cmd "$P/CoopZero.uproject" -game -nullrhi -unattended -nosound -ExecCmds=quit -abslog="$P/Saved/editor-game.log" with the same DDC flags logged LogCoopZero: Display: VERSE_INTERACT_OK exactly once.
  • Date / by: 2026-11-24, Coop Zero Step 01.

GameMode dispatches on startup and the callback leaves Who unused. Player input, non-null pawn handling and rendering need separate checks. The retained Scene Graph component compiled alongside the probe. The Slice map exercises the actor callback.