Ok, I’m fairly new to the community and, to be honest, still haven’t even got my iMac in the mail yet – however, it will be here next week.
So, onto my questions … when I am all setup and ready to go, I have quite a few scripts I need to write fairly quickly and I was wondering what the best way to approach scripting in Unity is.
I plan to develop using C# and am hoping to be able to bring with me a good bit of my general practices from my regular development job – this would be, reusable code.
So … for the purposes of Unity, is it better to write an extremely long script where all the heavy logic is buried inside of the Update/FixedUpdate or event callbacks … or is it OK to create a large call stack and have a bunch of smaller reusable scripts attached to game objects.
For instance, say I have a series of AI Logic snippets, and in “Game A” I want to use Logic Steps 3-6 and in “Game B” I want to use 1-10 … I can break the logic “steps” out into their own separate scripts and attached the portions of it to the objects that need them … but in doing so, each object now has 1-10 (or possibly even 100’s) of little scripts attached to it …
So basically, my question is … as Unity is a Game Engine and it already takes a good toll on the system resources to do the internal work, and frame rates are always of the utmost importance in most cases, is a lengthy call stack a serious performance issue or a negligible one?
In the case of the AI script, what I would actually wind up doing is creating maybe a few scripts that had totally different logic and then break the ‘steps’ out into if/switch conditionals within the script and toggling them through the Inspector with public vars … so, it was probably a poor example, but I hope I made my point as far as the logic is concerned.
My hope is, I can make a series of scripts that are reusable and just have a ‘library’ of game scripts that I can quickly access and attach to objects or allow my game designer to attach and configure … allowing me to remove myself from the actual game logic as much as possible and just write the core functionality and expose the variable data through the Inspector … eventually winding up with a long list of agnostic scripts that can be used for just about any purpose, just configure them as you need them…
Now … I understand, my overall question might be a ‘duh’ thing … I’m already assuming I can do this with Unity from my existing experience … just curious whether or not it’s a viable approach, or if I should rethink my overall approach and go another way.
Thanks