[Help] Does anyone know a good method of making interchangeable scripts?
I've started prototyping a game that is planned on using a large number of different types of abilities.
It would be greatly beneficial if each individual ability could be handled flexibly, as I would like them to be highly customizable in real-time. Each ability may also be very distinct and different from each other, so simply using an "ability" class and feeding it different values isn't really an option.
Think: Pokémon moves. Many moves have basic similarities, but others have VERY unique effects, making it impractical if every attack held all information about every in-game attack's functionality, while still having the shared functionality as in-game attacks. They can also be customized, in nearly unlimited different combinations, used by many different users, and replaced over time.
I've experimented with class Inheritance and Interface, creating an "access" class that's called when an ability is used, and then write separate scripts inheriting from the "access" class. This method has allowed me to make scripts that are somewhat interchangeable, but also comes with unsatisfying limitations.
There's issues with communication between the script that triggers the ability, and the separate ability script, as it's strictly a one-way communication with little room for flexibility.
This also requires each ability to be a separate GameObjects/Prefabs in order to be used in the inspector, which I find to be less than ideal.
I'm not the most experienced programmer or game designer, so I'm wondering if there's some easier(-ish) method of making a number of scripts with different functionalities but shared uses easily interchangeable with each other.
Thanks in advance.
Answer by Laktoosi · Jul 19, 2018 at 07:10 AM
Could you use overriding? https://unity3d.com/learn/tutorials/topics/scripting/overriding
Your answer
Follow this Question
Related Questions
Question about protected and abstract classes. 1 Answer
Waring, using new keyword on monovehaviour. When im not using monobehaviour!? 1 Answer
Inheriting values from base class in c# 0 Answers
Define attacks to choose from 1 Answer
Suggestions for planning project tasks and organizing classes/functionality? 0 Answers