Skip to content
JBenda edited this page Oct 17, 2023 · 4 revisions

Unreal

General Information

For the usage in Unreal a plugin is provided which allows including ink JSON files as assets.

It provides the following objects:

  • AInkRunner: loading a story and managed threads
  • UInkThread: can be started by connecting to a story. Has different Events which can be triggered, most important:
    • OnLine(FString line, const TArray& tags): a line of story output was generated attention: tags are collected until a choice is taken, then cleared if this is a bad way to handle it feel free to state your opinion in a github issue
    • OnChoice(const TArray<UChoice*>& choices): a choice is to be taken, this are the options.
    • PickChoice(int index): select a choice
  • InkSnapshot: can be created with Snapshot() and loaded with LoadSnapshot(<InkSnapshot>) for more details, visit the inkcpp page
  • UChoice: a choice to select
    • GetIndex() get index for PickChoice
    • GetText() get text contained in the choice
    • GetTags() get tags attached to choice
  • FInkVar: because the plugin must be compiled without knowledge of the usage, template decution is no way to for determining external function arguments. Therefore all external functions must take FInkVars, which then can be queried what kind of type they include, and this type can be read.

Building

Instructions:

  1. create an unreal project and close it
  2. not down path to unreal project (PATH/TO/UNERAL_PROJECT) e.g. D:\Dokumente\Unreal Projects\InkDemo
  3. git clone https://github.com/JBenda/inkcpp.git
  4. cd inkcpp
  5. mkdir build
  6. mkdir plugin
  7. cd build
  8. cmake -DCMAKE_INSTALL_PREFIX=../plugin ..
  9. cmake --install . --component unreal
  10. compile plugin: \PATH\TO\UNREAL_ENGINE\Build\BatchFiles\RunUAT.bat BuildPlugin -plugin="PATH\TO\GIT\REPO\plugin\inkcpp\inkcpp.uplugin" -package="\PATH\TO\UNERAL_PROJECT\Plugins\inkcpp" -TargetPlatforms=Win64 Image of Compiled File Directory
  11. Copy content of the InkUnrealExample in PATH\TO\UNREAL_PROJECT\Content
  12. Start unreal project
  13. Select Level NewMap from the Content Drawer
  14. start level, for the control use the 1,2,3 and 4 Key to select the corresponding choice
    • in the main world is a MyInkRuntime instance which takes a InkAsset for the story to play
      • unreal_example shows different kind of interaction between engine and ink
      • TheInterceptor is a larger example story from ink
    • to create a InkAsset import a .ink. file or an inklecate compiled .json ← we will probably not in future keep high priority on json imports ...

A Record of the terminal side of the build process can be found here

The Data can be found here: Example Data