Unity 3D and Inform integration

I think it would be great if it were possible to integrate Inform 7 with Unity 3D game development. I want to introduce more people to the IF world and make a hybrid 3d adventure/text adventure game, but don’t want to create my own parser. Inform 7 seems very advanced and I would love to use it in my game.

Is it already possible to do this? There’s a plugin on the Unity asset story called Tidy Text Adventure but it is no longer under any support from the creator. Any help or ideas would be great! Thanks.

I’m not sure if it is right now, to my knowledge. There’s not a strong Unity fanbase around here. But is it possible at all? Hmmmm…

I can envision something like a split-screen, with a 3D world on one side, and a text console on the other. How would they interact? Perhaps you could move the mouse around in the Unity view and click on things, and Unity would send text commands to the virtual machine. Or perhaps you type specific commands in the virtual machine, which sends a message to Unity to play an animation or follow a script.

The former would probably be easiest to set up, programming mouse clicks into a single command, though it would play more like a graphical adventure with text, than a text adventure. The latter would allow a much richer parser, and you might be able to do something like saving values somewhere for Unity to pick up and read – I suspect you’ll have to do a lot of tinkering with both Glulx and Unity to get such a thing working. But I do think it is possible.

I don’t believe that’s currently possible, and I’m not sure how doable it is even in theory. Still, interesting to think about. Would you be aiming for something similar to the 3D Vespers project?

Thanks for the reply! I was actually thinking of something along the lines of the first Leisure Suit Larry text/graphic adventure but being able to switch back and forth between text input and scene clicking or something along those lines. But, your suggestions could work. I guess I will have to look into Glulx, but would there be a way to use the Inform 7 parser in Unity at all?

I’m not sure how the language works, but am creating a text adventure in Inform 7 to get familiar with it, then seeing what I can do with Unity integration.

3D Vespers looks like an interesting project! Not sure if it’s still in development but I hope it is! I would like a choice, though, between text input and normal game controls - be it point-and-click or 3D controls. Honestly it does seem complicated and might just stick with graphical additions like the old Leisure Suit, but I like the more natural language and complex conversations capable with Inform 7, as in Emily Short’s work.

It depends on what level of integration you’re thinking about. It’s worth noting that Inform 7 and the parser are not quite the same thing. Inform-compiled stories are run in a virtual machine, either Z-machine or Glulx. Having Inform compile stories into C# or UnityScript or other Unity-supported format is not feasible. You’d need to implement the virtual machine in Unity which would then run the story file, with some modifications that would allow the story file to communicate with Unity and share some of the game world and state information. (Then it wouldn’t be Inform 7-specific but you could use anything that compiles into Z-machine or Glulx.)

Another way would be to re-implement the parser in native Unity code, but then of course you’d lose the world model, extensions etc. that Inform has.

There are interpreters you can use which talk over streams. You could theoretically connected this up to another process which would display it using Unity. But considering how few IF stories even include 2D images, this will be a very major departure from the norm. Not that that’s a bad thing - many of the important and good IF departed from what was the norm at the time. But I personally think you’ll need good reasons for the 3D other than it looking cool.

Ah, I get it. So Inform isn’t what I want, it’s Z-Code or Glulx that I need to look into (or similar parsers - if those 2 are parsers if I’m understanding correctly). I will see what I’m able to do, because I doubt I could create my own parser to be interesting enough.

This sounds interesting! What do you mean by talking over streams? I need to look into these interpreters.

And also, I should clarify what I’m talking about for needing a text adventure implementation for my Unity game (I think IF is great, and it doesn’t need graphics - though some of those 2D graphic text adventures can be pretty cool):

I am making a 3D game and the main character lives in his apartment where he mainly uses his PC. I want the main character to have access to a text adventure on this PC that he can play when on his PC. And at a certain part of the game, I want some of the text adventure mechanics to invade his dreams. During this dream he needs to use text input to get around the world and solve puzzles to end the dream. After the dream, it is back to normal 3D controls.

I was highly influenced by the book Ready Player One by Ernest Cline and the game Frog Fractions by Twinbeard Studios.

But, who knows, the game idea might be too complicated, but I’m in the process of prototyping right now…

Thanks everyone for your replies and help!

Am I able to close this thread so I can post a detailed thread in a more appropriate section of this board like “General: Interpreters, Add-Ons, and Tools” or “General Game Design” instead? Thanks to your help I realize now that I don’t need Inform, but some type of interpreter or parser that I can possibly integrate with Unity.

Feel free to post, you can just leave this thread open in case anyone else ever wants to add to it.

One possibility for Inform I didn’t see mentioned is to embed an Inform web interpreter within an iframe in Unity. Then perhaps it would be possible to use something like Vorple (sort of a web-based extension to Inform) to communicate with the Unity container embedding the iframe. Alternatively, I think there are also more low-level javascript functions available in Inform web interpreters like Parchment to communicate with the javascript host.

Well, I think that’s not quite it. Here is the situation, as I understand it:

The z-machine and Glulx are virtual machines. They each give you a way of taking what’s called a “story file” and running an IF game from it. What that means is, someone writes an interpreter program that implements one of these virtual machines; when you run that program, you can open up a file of the proper format and run a session of IF that will work according to the specifications of the virtual machine. Story files for the z-machine usually have extensions .z5 or .z8; story files for Glulx usually have extension .ulx. (There’s also file formats like Blorb that can wrap up a story file with other files, like the file for the cover art, but don’t worry about that for now.) So for instance Gargoyle contains interpreters that can run z-machine and Glulx files when you run the Gargoyle program on your PC (there are Gargoyle versions for Mac, Windows, and Linux, at least). Quixe is a Javascript interpreter for Glulx that you can use to let Glulx games be played on the web. There are z-machine implementations on mobile devices in various apps. And so on – these let the same story file be played on lots of different platforms.

There are actually two languages called Inform, Inform 6 and Inform 7. You can use these languages to write story files for z-machine and Glulx; so you write your program, and when it’s ready Inform outputs a .z5, .z8, or .ulx file. This file can then be shared in various ways; if you just send someone the file then they can play it if they have an interpreter that works for their platform, or you could wrap it up with one of the online interpreters so it can be played on a web page, for instance. There are in theory other ways to make z-machine and Glulx files but I don’t know if any of them are practical now (there was someone who had another language that compiled to z-machine but I understand that its output tended to be very buggy).

The parser is the part of the game that takes the commands the player typed and turns them into stuff for the game to do. Inform 7 has a lot of very useful default behavior built into the parser. For instance, if you write a game in Inform 7 that has an object in it (like this: “The Cave is a room. A rock is in the cave.”), then the game that it produces will automatically understand “get rock,” “take rock,” “pick the rock up,” “pick up the rock,” and some others as commands to pick the rock up. But it’s possible to add things to the parser or even override the built-in behavior if you want. (For instance, this dopey game of mine was written in Inform 7 and overrides the default parser behavior.)

So: if you were able to get an implementation of one of those virtual machines up and running in Unity, then you could use Inform 7 to write a game in that format, output a story file, and have your Unity game start the virtual machine running the story file within the game. This is a prospect that I personally would find extremely intimidating! The things other people have mentioned about Vorple, Parchment, and interpreters that output streams could be other ways of integrating story files with Unity. (I don’t know much about how that might be done, or anything really about Unity, but you would probably have to look into the guts of what’s happening a bit there.)

Another thing you could try to do is write your own kind of interactive fiction format that you could implement directly into Unity. I think this is what Frog Fractions did. This would be a lot of work and almost certainly won’t have the same sophistication of a parser that an Inform 7 game has (I haven’t tried “pick up the whatever” in Frog Fractions, but I bet it doesn’t work), but given the project you’ve described a relatively simple implementation of the text game might be suitable to your purposes.

Good luck! An z-machine or glulx engine that could be implemented into Unity would be pretty awesome, so I selfishly kind of hope you look into that.

There are a couple of Z-machine interpreters that are written in C#. It’s possible to integrate a C# library into a Unity project, right?

Start there, then figure out how to make the interpreter engine output to a Unity display object. I have no idea how that works but it must be possible.

There’s also the problem of making the Inform game and the Unity game react to each other’s state. There are a couple of ways to do this; logically pretty simple but it requires some tedious hacking.

FyreVM and Zifmia would be perfect for this sort of thing.

David C
www.textfyre.com

Yes, I just found out about Parchment but wasn’t sure how to incorporate it, so what you suggested might work. I need to look into it. Thanks!

Wow, thanks man! I was really confused on how parsers, interpreters, Glulx, z-machines, et cetera all worked. This really helps! So if I do get something up and going I will try to make in a package for the unit asset store. But there is already a tool called Tidy Text Adventures by Doppler Interactive on the Unity asset store that I am now fiddling around with. It is really cool, but lost support after release, but the developer went on to bigger things with one of his games and pointed me to the source code in the package. I will try and see how well it works and see if I can emulate some of Inform’s more advanced parsing. If I get the tool to work well enough and functional I will ask the permission of the developer to release it free on the asset store.

And by the way, your Fingertip game is incredibly deep! I love it :slight_smile:

I didn’t know there were interpreters in C#! That’s the language I use in Unity. Now I wonder if these z-machines are as advanced as Inform, because I DO want to control the character but I want the type of natural conversations that more modern games can achieve, especially like Emily Short’s work (I really wish I had an iPad to play her new IF game Versu).

Holy ****! This is exactly what I need to get started! Thanks!

I am starting to put all the pieces together, but obviously any extra help is appreciated :slight_smile:

Inform compiles the story files, which can then be played on any Z-machine or Glulx interpreter. The original goal of the Z-machine was to maximize portability by not requiring every story to be recompiled for every platform.

Oh that’s right. Keep getting the terminology and purposes all mixed up. This is turning out to be a more achievable task than I originally thought. I also have a coder friend that I could get involved with this, and I think he’d enjoy the task as much as I will.

I have newer versions of FyreVM and Zifmia from what’s on SourceForge. Everything there needs to be updated.

David C.
www.textfyre.com

Awesome! Would I, please, be able to get access to them by chance?

See my Zifmia post…also github: github.com/ChicagoDave/Zifmia

David C.
www.textfyre.com