Add a Custom Command
A command is a request that enters the simulation and runs on every machine at the same tick. Moving, attacking, building and harvesting are abilities, not commands: author those as abilities. Add a command only for a request that is not a unit’s verb, such as calling the next wave early, a team-wide toggle or a match-level choice.
Every command is checked before its handler runs:
- Schema. The command type is known, its data is the struct the type declares, and the number of entities fits.
- Match context. The match is in a state that accepts it.
- Authority. The authority policy allows this player to issue it.
A command that fails any check is rejected, and presentation hears a Command Rejected event with a reason tag. The handler only ever sees commands that passed.
This guide adds Call Wave: a player asks for wave N to start early, and the simulation counts the request on their Player State.
1. Add the command type tag
Section titled “1. Add the command type tag”Open Project Settings > Project > GameplayTags and add SeinARTS.Command.Type.CallWave. Keep it under SeinARTS.Command.Type, and not under .Observer: observer commands are recorded for replays and change nothing.
2. Define the data
Section titled “2. Define the data”The command carries a small struct. It follows the same rules as any simulation data: fixed-point or integer types, no float, no pointers.
The data struct is a C++ struct, because the function that issues the command builds it in step 5:
USTRUCT(BlueprintType, meta = (SeinDeterministic))struct FCallWaveData{ GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Wave") int32 WaveIndex = 0;};Also create the state the handler will change. Add a SeinARTS Actor Component SC_WaveState with an Integer variable Calls to your Player State Blueprint.
3. Create the handler
Section titled “3. Create the handler”- In the Content Browser choose Add > Blueprint Class, open All Classes, and pick Sein Command Handler. Name it
CH_CallWave. - In Class Defaults, set:
| Setting | Value |
|---|---|
| Command Type | SeinARTS.Command.Type.CallWave |
| Data Schema | Call Wave Data (FCallWaveData). Only the struct’s type counts; the values you set here are ignored. Leave it empty if the command has no data. |
| Authority Scope | Self: any registered player may issue it. Entity and Entity Set require entities on the command and check the player controls them. Match Control is for the match administrator. |
| Allowed Execution Contexts | None. The command then runs only while the match plays and is not hard-paused. Add Hard Pause or Starting to allow those. |
- Open the Execute Command override. Its inputs are the World and the Command, and its outputs are the Return Value and Out Rejection Reason.
- Build the graph:
- Break Sein Command. Pass the Data to the engine’s Get Instanced Struct Value node, wire its Value pin to a Break Call Wave Data node, and continue from its Valid exec pin.
- Branch on Wave Index below
0. On true, set Out Rejection Reason toSeinARTS.Command.Reject.Malformedand return false. - Get Player Entity on the World, with the command’s Player ID.
- Apply Field Delta on that entity: Struct Type
SC_WaveStateData, Field NameCalls, Delta1. Wire the World into its World Context Object pin. A handler has no world of its own, so the node fails without it. - Return true.
Returning false rejects the command, with the reason you set. Returning true marks it handled.
Compiling checks the handler’s class settings. Asset validation, on save or from Validate Assets, checks its graph, the same way it checks abilities. It reports every call it has not audited, which includes Get Instanced Struct Value and Get Player Entity in this graph. Both only read, and the report does not stop the match. The handler must be stateless and deterministic:
- It never writes a member variable. One handler instance serves every caller. Keep working values in function-local variables.
- It uses fixed-point and integer types, and no
float. - It does not use Spawn Actor, Construct Object or Get Subsystem nodes, or nodes that submit commands for a player.
4. Register the handler
Section titled “4. Register the handler”Open Project Settings > Plugins > SeinARTS, category Commands, and add CH_CallWave to Additional Handler Classes. The set of handlers is fixed when a match builds, so restart the Play session after you change it.
A bad entry stops the match from building, so no command runs, orders included. The log reports “Commands disabled: the handler class … is missing, abstract, deprecated or mutable.” Each entry must be an existing, non-abstract Blueprint of Sein Command Handler.
5. Issue the command
Section titled “5. Issue the command”The framework has no Blueprint node that submits a custom command for the local player. One small C++ function adds it, and Blueprint calls that:
UCLASS()class UMyCommandLibrary : public UBlueprintFunctionLibrary{ GENERATED_BODY()
public: UFUNCTION(BlueprintCallable, Category = "MyGame|Commands", meta = (WorldContext = "WorldContextObject")) static bool CallWave(const UObject* WorldContextObject, int32 WaveIndex);};
bool UMyCommandLibrary::CallWave(const UObject* WorldContextObject, int32 WaveIndex){ const UWorld* World = WorldContextObject ? WorldContextObject->GetWorld() : nullptr; USeinWorldSubsystem* Sim = World ? World->GetSubsystem<USeinWorldSubsystem>() : nullptr; USeinCommandDispatcher* Commands = Sim ? Sim->GetService<USeinCommandDispatcher>() : nullptr; if (!Commands) { return false; }
static const FGameplayTag CallWaveTag = FGameplayTag::RequestGameplayTag(TEXT("SeinARTS.Command.Type.CallWave")); FCallWaveData Data; Data.WaveIndex = WaveIndex; return Commands->SubmitLocal( FSeinCommand::Make(Commands->GetLocalPlayer(), CallWaveTag, Data));}Include Simulation/SeinWorldSubsystem.h and Input/SeinCommandDispatcher.h, and add SeinARTSSimulation and GameplayTags to your Build.cs. In a Blueprint button, call Call Wave.
SubmitLocal returns true when the command was accepted into the pipeline. In a network match it goes to the host as part of the next batch, and the host stamps your player on it. A client cannot send a command as another player.
For a computer player, call Emit Command from the AI controller’s On Sim Tick with a command made for the AI’s player. It is valid only from On Sim Tick.
Test it
Section titled “Test it”- Play with two players, or with one against the computer.
- Click the button. In a network match, after about 300 to 400 ms (the input delay), or on the next tick in a standalone match,
Callson your Player State is1on every machine. Read it with Get Attribute on the player’s entity view model. - Type
Sein.Commands.ShowLogin the console. A line forSeinARTS.Command.Type.CallWaveappears with your player and tick. The overlay needs a HUD derived from Sein HUD. See Debug Views and Profiling. - Issue it with
WaveIndexset to-1.Callsdoes not change, and a Command Rejected visual event carryingSeinARTS.Command.Reject.Malformedreaches On Visual Event Dispatched.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause |
|---|---|
| Rejected as UnsupportedSchema | No handler is registered for that tag. The handler is not in Additional Handler Classes, or the tag differs. |
| Rejected as Malformed | The data is not the struct the handler declares, the data is missing or unexpected, or the entity count does not fit the scope. |
| Rejected as Unauthorized | The authority policy refused. A defeated player may issue only observer commands. |
| Rejected as MatchStateInvalid or SimPaused | The match is not playing, or is hard-paused. Add the context in Allowed Execution Contexts. |
| The match does not build, and the reason names the command path | A handler entry is invalid. Read “Commands disabled” in the log. |
| Asset validation reports the handler as non-deterministic | A node or variable breaks the rules above, or the call is one it has not audited. Fix a node that writes or reads outside the simulation. |
Nothing happens and SubmitLocal returns false |
The match is not running, or you called it from inside the simulation or from a read-only callback. Commands for a tick are submitted by input code, not by abilities. |
| The Data Schema picker is empty | The struct is not marked SeinDeterministic, or its module has not compiled. |