Skip to content
Bryan Legend edited this page Mar 5, 2023 · 10 revisions

We are using Yarn Spinner for cinematics. See https://docs.yarnspinner.dev/

File Location

.yarn files are stored in the /Assets/Dialogs folder. Each new .yarn file needs to be added to the Yarn Project in unity and have Apply clicked. When that button is clicked is when the yarn files are parsed and if there are parse errors they will show on the unity Console tab. Check the Unity Console tab for errors.

We may replace this pre-processed system with loading the .yarn files directly at runtime.

Yarn nodes must be unique across the entire game.

Dev Console Integration

There are the console commands DialogStart and DialogData available to interact with the Yarn system.

Any unrecognized << >> tag in a yarn dialog script will be passed and run as a dev console command.

<<Souls 300>> // gives 300 souls
<<Remove BarnabusKey 1>> // removes an item from the player
<<Shop Melee1,Ranged1>> // shows a shop menu
<<Give Health 10>> // gives ten items to the player

Triggering Yarn Nodes

  • Use the DialogStart console command. This is great for testing.
  • Create an NPC with the same name as a yarn node, via a Tiled object layer.
  • Place a Trigger prefab with the same name as the yarn node, via a Tiled object layer.

Yarn Features

Yarn supports localization and voice overs, both of which we would like to use eventually.

Available Functions

  • Has(ItemId) - check player inventory.
  • SoulCount() - checks player soul counts.
  • WaitForMenu() - Blocks the yarn runner until all menus are closed. You need to run this after showing a shop menu, etc.
  • PromptForNumber() - Shows a number dialog and stores the result in a Yarn Variable.

NPC Variables

Place an NPC in the game world using the object layer, then set the NPC name to a yarn node. You can add custom properties “Equipment.Items”, “NPC.HideVariable”, “NPC.ShowVariable” to control the look, equipment and when an NPC is visible based off of a Yarn variable.