vitor_nilk

LD28

Any references on how to handle RPG events in Unity 3D?

Hello there,

I am working on this RPG game in Unity and I’ve come to the point where I need to develop the system for handling events. The thing is, I have a class called “interactable”, and that class is supposed to serve everything from NPCs to treasure chests and doors. Programming the behaviour of each instance in the instance itself (in the case of Unity, in the prefabs’ scripts) is, however, definitely not the way to go. I would like a way to express how interactables should behave (NPC dialogue, items contained in chests, etc.) from an external file (probably a text file) and load the pertinent interactable data depending on the room (scene) I’m in. Any tips on how to start on that?

Moreover, I need a way to handle the events that these interactables will trigger. I’ve looked at this reference for event handlers in Unity with C#: http://www.everyday3d.com/blog/index.php/2010/10/04/c-events-and-unity3d/ , which already helped me a bit, but I’ve thought of basically two ways to implement this in a game-wide system: Either one event controller per scene, which would have information on the events that could happen on that scene and handles all of it (activates listeners, etc.); or a game-wide event controller (a singleton), with information about events from the whole game. Which do you think is better? Or would you rather go with another alternative?

Thanks in advance for the replies

Comments

16. Mar 2014 · 06:31 UTC
I’m no expert. In fact I was aiming to start making an RPG type of game but got side tracked. However I did research it a bit. The needs will of course depend on what type of RPG. But anyhow. There are som fairly slimmed xml readers one can use for unity. Should be easy to find by googling. That could solve type first problem.