1
\$\begingroup\$

I've made a turn-based game (think xcom) in Unity, and because I don't need real-time, asynchronous elements, or physics calculations I decided to make a pure c# Model (in the sense of Model, View, Controller) which everything is based on. I use Unity and a MonoBehavior based game loop to handle rendering, camera, UI and input, but stuff like a character attacking another and then calculating a counterattack, or player equipment and spells, are all pure c#.

Am I missing some capabilities of Unity that I should be looking at or is this a basically reasonable approach?

\$\endgroup\$
  • \$\begingroup\$ If it works for your game, then it sounds fine. Is there a particular feature or piece of functionality that you feel like you're missing? \$\endgroup\$ – DMGregory Mar 25 '17 at 20:05
  • \$\begingroup\$ Generating complex chains of input options for the user (click a unit to move, click a square to move to, click another square to move to, confirm, render ghost path at each step) and allowing complex chains of attack, counterattack, etc. have proven a little tricky. I don't know that something in unity offers a better option though. \$\endgroup\$ – Elliot JJ Mar 25 '17 at 20:31
  • 2
    \$\begingroup\$ I think you're likely to get more targeted, higher-quality answers by asking about how to implement that specific feature then — especially if you're able to diagram out each step you need to coordinate. \$\endgroup\$ – DMGregory Mar 25 '17 at 20:34
1
\$\begingroup\$

The two are not mutually exclusive. It's a reasonable approach as long as your comfortable working that way. I assume when you say pure C# you're still using MeshRenderer components, gameObjects, etc.

I've worked this way before in Unity, especially early on as I came from Objective C and had written a bespoke 2D Sprite system, and instinctively wanted to work the same way and have a lot of manual control.

I realised though, and this applies to your situation, that there is a certain fundamental design in Unity that can be difficult to work outside of without constantly wrestling with those paradigms. Then add to that the fact that there's a lot of functionally there that can speed up a workflow that you might be ignoring.

User input you mentioned is a good example. If you're not using camera-sourced raycasts and component lookups on the hit results, you might be instead doing it an unnecessarily harder way (I can only speculate).

I'm still code heavy in approach myself, and slightly more OOP than the recommended dosage. I use quite a feature-full boilerplate framework filled with convenience methods and shortcuts, but I also use and respect all of Unity's component based approaches, and editor features. I still get annoyed how so much "magic" process goes on behind a curtain, but I live with it.

Bottom line is I have benefitted greatly from adapting to and appreciating Unity's flow, design, and systems.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.