I’m now fully committed to the Spaceteam rebuild.
It’s a big investment in the future of all my games and the sooner it happens the better. I’ve been wasting too much time tracking down obscure bugs which will soon become irrelevant, so I’ve stopped development on the 1.8 branch until the new version (2.0) is ready.
Sorry to everyone currently experiencing crashes, you’ll have to wait a bit longer for a fix. Thanks for your patience!
In the end I decided to go with Unity 5 and I’m really enjoying it so far.
The UI system makes it easy to scale and anchor elements so they work at different screen sizes. This was a pain to get right before and annoying to test, so the new system is a pleasure to use.
The Particle system is powerful enough that I can directly recreate most of the effects I was using. I can now use Animations for some sequences I was previously doing in code.
There are handy built-in features like Serialization and JSON parsing that I get for free.
And I love being able to easily make custom visualizers and editors that work right in the Editor.
Here are some more notes on how I’m using Unity:
Project Setup
- I’m using C# for the CaptainsMess networking portion and Javascript for the game code. But I’m considering moving everything to C# so I can get full debugger support (I’m assuming you can’t do source-level debugging in Javascript?).
- I use Sublime Text 3 on the Mac as my script editor, but I’m also looking at Visual Studio Code which has some nice integration features and debugger support. VSCode also works much better with C# than with Javascript.
- I’m trying to use plugins from the Asset Store as much as I can. These are the ones that have sparked my interest so far:
- I2 Localization. I have 12 languages to support!
- xARM. Useful for testing multiple screen resolutions on different devices (iPhone 4, iPhone 6, iPad, Android tablet, etc)
- Google Sheets for Unity (GSFU). Handy for getting simple data tables into the game, like level progression.
- TexturePacker Importer. I already use TexturePacker to make sprite atlases for the Cocos2d version so I assume it will help here as well, although Unity has some built-in sprite packing so maybe I won’t need it.
- Editor Console Pro. Search, filters, and colours for the debug console.
- VSCode. Integration for the VSCode editor.
- PlayMaker. I had heard good things about this tool so I wanted to check it out. I like being able to create state diagrams that not only provide a high-level view of the game logic but are also functional. I still haven’t decided whether I’ll use it in production.
#
Networking
- At first I looked at the Photon framework but it turned out not to be a good fit for Spaceteam. Most of their services are online rather than local and if I want to use their Redistributable Server license it seems I’d have to pay for every 500 users, which is totally untenable for my needs.
- My current plan is to just use the built-in Unity Networking. I don’t have to pay for it and it covers most of what I need already, so the CaptainsMess library may end up being a relatively thin wrapper around it.
- The main classes I’m using are part of the High-Level API: NetworkManager and NetworkDiscovery
- The NetworkManager class can start a server or client but has no discovery
- The NetworkDiscovery class can broadcast and listen for other devices but has no server/client code
- For the initial connection I’m also using NetworkLobbyManager and NetworkLobbyPlayer
- These classes already track “slot” (ie. player index) and “ready” state so I don’t have to
- The main thing I’ll have to add is the ability to search for games as a server and client at the same time. The current system only supports one NetworkManager object so I’ll have to work around this with some lower-level code.
- This networking system seems to be quite new and I’ve encountered a few weird bugs and idiosyncrasies but they’re pretty minor so far.
- Luckily, Unity has made the source code available which makes it much easier to debug and modify: https://bitbucket.org/Unity-Technologies/networking
General Tips
- Remember to set “Playmode Tint” in Editor prefs so you don’t lose changes you make in Play Mode!
- Don’t name Prefabs the same as Instances!
- If you’re doing things with a networked Player object remember to check isLocalPlayer to avoid redundancy and confusion.
- Changing a child object name after animating its properties breaks the connection and marks it “Missing”.
Reference for mixing C# and Javascript:
http://docs.unity3d.com/412/Documentation/ScriptReference/index.Script_compilation_28Advanced29.html
- Extend data classes from System.Object if you want them to be inspectable in the Editor (add [Serializable] in C#)
- You can’t define generics in JS, but you can use them (with dot before brackets: List.
instead of List ) - Use builtin array[] in Javascript instead of Array if you want to see the items in an inspector.
I know that a bunch of you already know Unity so maybe you can help me answer some questions that I have.
My Questions
- Can I rearrange folders in Assets or should all extensions/plugins live at the root level? I’d like to put packages I download from the Asset Store into a subfolder but whenever I update something it wants to import it at the root level.
- Any tips for using the Animation Controller system as a regular state machine with transitions triggered in code? (eg. for abstract game states like Lobby, Setup, Intermission, Playing, etc). And if I do this should I be using “Trigger” parameters or just go directly to the state with Play(“StateName”)?
- If I have a bunch of unique objects (eg. UI screens like Title Screen, Credits Screen, etc.) should they all exist in the scene and get Activated/Deactivated as needed? Or should they only exist as prefabs and get Spawned when needed?
- How do you ‘diff’ scene files in source control (I use Git) to find out what changed? I’ve found some methods for saving them as text and plugins that claim to solve the problem but it seems like it could be error-prone. What do you recommend?
- Is there an advantage to separating things into Scene files if your game has very little content like mine? Will it be ok to have everything in one scene?
I’m officially on holiday now but I’m looking forward to continuing the project when I get back.
Thanks for listening and Happy Holidays!