Spreadsheets and Decision Tables

I’m working on prototyping a fully 3D adventure title along the lines of the old Sierra adventures. Right now I’m in the process of developing my control interface but wasn’t sure how to approach the way characters actually interact with objects in the game.

Specifically, the character can do one of four things with an object: He can Look at it, Interact with it (either by manipulating it in some way or by picking it up and adding it to inventory) use an Inventory item on it (IE, cutting a rope with his knife or sword for a physics-based puzzle) or attempt to Talk to it. I’m looking for the most efficient way of doing this across a WIDE variety of objects as possible.

I could certainly do a script for each object outlining what the game’s response would be depending on how the character is interacting with it, however considering just how MANY objects there would be in the game (possibly even the prototype depending on how complex I decide to make it) this would require a LOT of scripts. While prefabs might work for SOME things, even two obects of a type (IE, two rocks) might not be able to be interacted with in the same way (one rock may be able to be pushed over, while another of the same size and weight may be immovable because it’s stuck in the ground, or has something blocking it that needs to be moved first, etc). I suppose I could also use prefabs for objects that would give the same responses and separate out the unique ones.

One thought I’d been having was to use a spreadsheet to record every item that can be interacted with, and the subsequent cells listing what the game will do if a particular action is taken. The Control script would then reference this spreadsheet by finding the item in the list, determine what action is being taken, and return the appropriate response.

Any thoughts on which method to pursue? Would the spreadsheet even be possible?

Related to this, can the Unity engine be set up to reference Decision Tables? I want to create a fighting system that’s highly complex and dynamic, with controls that are still very simple for the player. IE the player clicks LMB to swing his sword, but whether the character makes a falling or rising cut is determined by criteria pulled from a Decision Table (with factors such as distance, skill with a particular weapon, etc) rather than any specific action taken by the player themselves. So a circumstance that meets X, Y and Z conditions would then fire off one attack animation, whereas for the same input if the conditions are X, B and C it would use a different one.

Unity does not work with spreadsheets. I guess if I was faced with your problem, I might be tempted to use a spreadsheet to allow me to enter the data, but then write some code that takes this spreadsheet and generates scripts from it. I think if your game has a lot of object types and a lot of interactions between them, then you’ll need a lot of code.

You can absolutely use CSV (write your own importer, unless C# supports it, I haven’t checked), so you could do anything you like in a spreadsheet and export it as CSV (or any delimiter you like). You can also export CSV from Unity back to the spreadsheet. I’ve done this with editor scripts to manage large real-world systems.

I’ve been working on a set of scripts which would interface directly to spreadsheets to make this all easier, to put in the Asset Store sometime later this year.