- Home /
Event system vs separated scripts
Hello, I am working on a game with a lot of events like dialogs, objects comparison and door opening. I was wondering what is the best thing to do between writing an Event System (An NPC will have actions to do one after the other) or add a new script to each NPC with it's own actions.
What really blocks me is that if is use the event system, some NPCs may have some unique actions (like an animation or a script) only used by them and i won't add it to the event system. So is it better to only use scripts or write the event system (Which is not really a problem, Odin is even better to make it work)
Thanks!
Answer by GameGuy · May 28, 2018 at 11:50 AM
I guess there is no "right answer" here, it really depends on project size, game type, skill of team and so on... When you have a good scope of what the game mechanics will be and good documentation is also no big deal you can combine both worlds and use their advantges. Create basic Event systems and do the fancy stuff modular on per script base.
Answer by Willfree · May 28, 2018 at 03:45 PM
I see.. so Event system for basic and common actions and scripts for complex events.
Actually, i work alone on a project which requires a lot of events. I've made a working event system. It's just something i needed to know before implementing something that won't be optimized or useless.
Thank you for your answer.
You can always make a base class which inherits monobehaviour, and build some basic behaviour to handle events in a generic way. You can then use that baseclass as a base for all your events which will make life easier. This is an option to do it script by script. (depending if u inherit from monobehaviour or not).
What i did is create the Event System with a base class and inside it has many other classes which are actions done one after the other. So i added one which calls a script.
$$anonymous$$y Base Event class contains a class called "Action" and a list which stores these actions. Each action have an enum with every type possible (show a dialog, manage the items, compare a value) and the player or the reader will loop in the actions list.
The action class also have it's own classes, one for each type to set different values every time.
(Also, i am using Odin to make it work better)
Your answer
Follow this Question
Related Questions
UI Button : Previously working but now it's not working 0 Answers
How can i add a event onclick for a ui button that is child of canvas ? 1 Answer
Importing Post Processing Stack didn't clear the errors 0 Answers
Advice on reducing amount of direct referencing. 0 Answers
Add Button Script to 3D gameObject 1 Answer