Skip to main content

CommandGraph: Node-Based Event Scripting

The CommandGraph is MCE's visual scripting system for creating NPC behaviors, cutscenes, quests, and interactive events. It provides a node-based editor where you connect commands to define event sequences -- no C# code required.

This is the primary tool for game designers working with MCE in every edition, including the compiled editions where the source code is not included.

What a graph produces

That box is the output of a two-node graph: a sign the player interacted with, and one ShowSignDialog command. Nothing about it was written in C# — the same shape scales to a branching cutscene, and the runtime does not know the difference.

What is CommandGraph?​

A CommandGraph (ActorCommandGraph) is a node graph stored on an Actor (any interactable entity in the world). When the actor is triggered, the graph runs as a coroutine, one node after another.

Every actor has several graph slots, one per moment you may want to react to:

SlotRuns
On Enable Command GraphWhen the actor is enabled.
Loop Command GraphOver and over, while no other graph of the actor is running.
Interact Command GraphWhen the player interacts with the actor.
On Demand Command Graph 0 to 3Only when another graph asks for it (RunOnDemand, RunMultipleOnDemand).

Specialised actors add their own slots: TriggerActor has the "player about to enter / entered / about to be teleported / teleported" and "actor pushed inside" graphs, ActorCharacter has the "spot player" graph, and PushableActor has the "push" graph.

Think of a graph as a visual script where each node is a game action:

[Root] → [ShowDialog] → [IfPlayerHasBadge]
├─ True → [GivePlayerItem] → ...
└─ False → [ShowDialog: "Come back later"]

Creating Your First Event​

Step 1: Create an Actor​

The quickest way is the Hierarchy menu: right-click and choose GameObject > MCE > one of the ready-made actors:

MenuCreates
Blank/Character, Blank/EmptyTrigger, Blank/InvisibleAn empty character, trigger or invisible actor to fill in yourself
NPCs/Simple dialog, NPCs/Give item, NPCs/Give monsterAn NPC with a ready dialog, item gift or monster gift graph
Trainers/Static, Circle, Look around, Random look around, Random walkTrainers with the usual behaviors
Other/Sign, Pick up item, cuttable trees, breakable rocks, boulders, whirlpoolsThe classic overworld props

You can also add the component yourself. The concrete actor types are:

Actor TypeTriggerUse Case
SimpleActorPlayer interacts (no graphics or extra logic)Invisible interaction points
ActorCharacterPlayer interacts; can walk, look around and spot the playerNPCs, trainers
TriggerActorPlayer steps onto it (does not block movement)Auto-triggers, warps, hidden events
ActorItemPlayer interacts, gives its item and disappearsItem pickups on the ground
PushableActorPlayer pushes it (an ActorCharacter)Boulders, puzzle blocks

Actor and GridSubscribingActor are abstract base classes; you do not add them directly.

Step 2: Open the CommandGraph Editor​

  1. Select the actor's GameObject.
  2. In the Inspector, find the graph slot you want (for example Interact Command Graph).
  3. Click Edit graph to open the node editor window. Delete graph clears it.

Step 3: Add Nodes​

  1. Right-click in the graph editor.
  2. Choose Create Command / <Category> / <Node>. The category is the node's folder (see below).
  3. Connect nodes by dragging from one node's output port to another node's input port.

Step 4: Configure Nodes​

Click a node to edit its fields in the Inspector panel: the text of a dialog, the item and amount of a gift, the tile of a teleport, the variable of a condition.

Node Categories​

These are the categories as they appear in the Create Command menu. The list below names the most useful nodes of each; the complete set is in the menu.

Dialogs​

NodeDescription
ShowDialogShow a common dialog
ShowChoiceDialogShow a dialog where the player makes a choice (one output port per choice)
ShowSignDialogShow a sign dialog
ShowNoSkippableDialogShow a dialog the player cannot skip
NextDialogSkip to the next dialog
ShowUsedMoveDialogA dialog telling a monster used a move
ShowMonsterPicturePut a monster's front picture in a framed window, or take it down

Variables​

Conditions and variable changes. Every If... node has two output ports, True and False.

NodeDescription
SetBoolVariable, SetIntVariableSet a game variable
IfBool, IfIntEquals, IfIntCompareBranch on a bool or on an int compared with a value (less, greater, equal...)
IfIntVariablesCompareCompare an int variable against another int variable
SwitchIntVariableOne output port per value of an int variable
WhileBool, WhileConditionLoop while a condition holds
IfPlayerCharacterIs, IfPlayerDirectionIsBranch on the chosen player character or the direction it faces
SetTemporalBoolVariable, SetTemporalIntVariable, IfTemporalBoolVariables of the running actor that are not saved with the game

Game variables are chosen through a variable reference (the global storage or a scene's storage). They persist in save data and can be read from any graph or script.

Items​

NodeDescription
GivePlayerItem, TakePlayerItemAdd or remove an item in the player's bag
GivePlayerMoneyGive the player money
IfPlayerHasItemBranch on whether the player has an item
ChooseItemDialogAsk the player to choose an item and run commands accordingly

Monsters​

NodeDescription
GiveMonstersGive monsters to the player (fixed species or random). Needs a grant id in the online layer: see Monster Gifts
HealPlayerRosterHeal the whole party
ChooseMonsterDialog, ChooseTwoMonstersDialogAsk the player to choose one or two monsters
ChangeMonsterNickname, RemoveMonsterNicknameRename a monster
MoveTutor, RemindPreviouslyLearntMovesTeach a move or remind past moves
IfMonsterCanLearnMove, IfRosterHasMoveBranch on moves
OpenStorageOpen the monster storage

Battles​

NodeDescription
SingleTrainerFightFight a single trainer
SingleWildFight, DoubleWildFightTrigger a fight against wild monsters
FightFromTemplateLaunch a fight from a battle template
RandomFightAgainstRandomRostersA random fight against one or two random rosters
StartTowerRunStart a Battle Tower run
IfCanHaveDoubleBattleBranch on whether a double battle is possible

Badges, Dex, Quests​

NodeDescription
GiveBadge, IfPlayerHasBadgeGive a badge / check for one
GiveDex, IfPlayerHasDex, IfDexIsComplete, RegisterMonsterAsSeenDex handling
StartQuest, UpdateQuestObjective, ProgressQuestObjective, CompleteQuest, FailQuestQuest progression (see Quest System)
IfPlayerHasQuest, IfCompletedQuest, IfQuestFailed, IfCurrentQuestObjectiveBranch on quest state

Animations​

Characters, the player and the screen.

NodeDescription
Move, MovePlayer, WalkToPlayerWalk a character, the player, or toward the player
Look, LookAtPlayer, ForcePlayerToLookTurn a character
JumpCharacter, WanderWithinRangeJump; wander around a start tile
HideCharacter, ShowCharacter, HidePlayer, ShowPlayerShow or hide graphics
MoveFollower, LookFollowerWalk or turn the monster that follows the player
FadeScreenToBlack, OpenDoorFade the screen; open a door on the actor's tile
PlayExclamation, PlayEmotionShow a balloon over a character: see Emotion Balloons and Emotes

Sounds​

NodeDescription
PlayMusic, StopMusic, SaveMusic, RestoreSceneMusicWorld music on top of the map's own
PlaySound, PlayMonsterCry, WaitForAudioSounds and cries

Shops, Trade, Saves, Breeding​

NodeDescription
BuyInShop, SellInShopRun the shop logic for buying or selling
TradeSelectedMonsterTrade the monster the player has chosen
AutoSaveIfEnabledAuto save if enabled in the configuration
StoreTwoSelectedMonstersInNursery, IfEggIsReady, BreedEggInNurseryAndGiveToPlayerThe nursery

Utils​

NodeDescription
TeleportPlayerTeleport the player to another location (validated by the server when online)
TeleportActorInsideScene, PlaceActorMove an actor inside the current scene
WaitTime, LoopXTimes, RunInParallelTiming and flow
LockPlayerInputLock or unlock the player's movement during a cutscene
SetActorActive, AutoDestroySwitch another object off, or destroy the actor
SwitchOnDayMoment, SwitchTimeOfDayBranch on, or set, the moment of the day
SetLastHealLocation, SetLastHealLocationToCurrentWhere the player reappears after losing
LogMessageLog a message to the console

Connecting Nodes​

The CommandGraph uses a flow-based connection model:

  • Each graph starts at a Root node.
  • Each node has an input port and one or more output ports.
  • Most nodes have exactly one output port (the next command). If... nodes have True and False; ShowChoiceDialog has one port per choice; SwitchOnDayMoment has one per moment of the day.
  • A node without a connected output port ends that path of the graph.

Example: Shop NPC​

[Root]
→ [ShowDialog: "Welcome! Would you like to browse my wares?"]
→ [ShowChoiceDialog: "Buy" / "Sell" / "No thanks"]
├─ "Buy" → [BuyInShop]
├─ "Sell" → [SellInShop]
└─ "No thanks" → [ShowDialog: "Come back anytime!"]

Example: Quest Giver​

[Root]
→ [IfBool: rescued_lost_monster]
├─ True → [IfBool: quest_reward_given]
│ ├─ True → [ShowDialog: "Thanks again!"]
│ └─ False → [GivePlayerItem: TM, 1]
│ → [SetBoolVariable: quest_reward_given = true]
│ → [ShowDialog: "Take this as thanks!"]
└─ False → [ShowDialog: "Please help me find my lost monster!"]
→ [SetBoolVariable: quest_find_monster = true]

Example: Gym Leader​

[Root]
→ [IfPlayerHasBadge: Boulder Badge]
├─ True → [ShowDialog: "You've already proven yourself!"]
└─ False
→ [ShowDialog: "I am the Gym Leader! Prepare for battle!"]
→ [SingleTrainerFight]
├─ On Player Won → [ShowDialog: "Impressive! You've earned this."]
│ → [GiveBadge: Boulder Badge]
└─ On Player Lost → [ShowDialog: "Train harder and come back!"]

SingleTrainerFight has three output ports: the plain next-command port, On Player Won and On Player Lost. The "lost" path only runs when the node is set not to respawn the player after a defeat.

Testing Events​

  1. Enter Play Mode in the editor.
  2. Walk your character to the actor.
  3. Press the interact button.
  4. The graph executes and you can watch the flow.
Debugging a graph

If a graph is not behaving as expected:

  1. Check the Console for errors.
  2. Verify that referenced game variables, items, and monsters exist.
  3. Make sure all output ports are connected -- an unconnected port silently ends that path.
  4. Add a LogMessage node to print values during execution.

Best Practices​

  1. Name your actors descriptively. "NPC_Professor_Lab" is better than "Actor (3)".
  2. Use game variables for state. Do not rely on actor enable/disable alone.
  3. Test both branches. Every If... node should work for both True and False.
  4. Keep graphs readable. Use spatial layout to make the flow clear. Group related nodes together.
  5. Reuse patterns. Once you have a working shop NPC, duplicate and modify it for other shops.
  6. Save before testing. CommandGraph changes are scene-level changes that can be lost if Unity crashes.

For the C# side -- running a graph from code or writing your own node -- see the CommandGraph API.