Wednesday, 14 October 2015

There is such a thing as too much compiler optimization

I spent my University years using antiquated subsets of C and C++, so I decided to try my hand at the latest Standards and Proposals.

After some time I found this weird... Bug? I had a GetNeighbours function that would fill out an array which was passed by reference. It spent a few days as an empty placeholder. Once I filled out the function so it would actually return the neighbours, I started getting compiler errors because std:array was undefined. How could this be? The function had been there for ages, and had always received an std:array parameter. Why was it only throwing out errors now?

The answer was simple but it took a bit of lateral thinking: The compiler had figured out GetNeighbours was performing no useful work and simply ignored it, not even caring that the type of argument was undefined. The function call had been removed and the code had never been compiled.

I'm ashamed to say this took me a few minutes to figure out.


This works
This doesn't (std::array is not a defined type)
This works. Wat?

Thursday, 10 September 2015

On moving from Unity to Unreal

The team at Titan is working on a soon-to-be-announced Top Secret Project. We've recently changed from Unity to Unreal and here are some things we've thought about sharing with other Devs that are thinking of making the jump.


The good stuff: 

  • Unreal let's you easily alter the aesthetics of your project. The drag and drop material editor, the huge amounts of built-in high quality content let you easily reach AAA levels of quality, even for small prototypes.
  • Blueprints are amazing for quickly prototyping concepts! Beware: any non-trivial math expressions will be a mess of wires, but thankfully there's a handy math expression node to help you avoid turning your code into a spaghetti mess.
  • The community has a lot of experienced developers, which makes useful content and non-trivial tutorials easier to find.
  • The architecture and the way everything is structured encourages newbie developers to write more robust code. Contrary to Unity, there's already a game state, game modes, an Actor-Controller model...
  • Epic's experience has led to so much high quality content that you can easily pick up something like the FPS Tutorial and merely have to tweak a few values to suit your needs - We recreated the movement style of our first Unity game (Slinki) in a matter of minutes.

The bad stuff:

  • The render pipeline is setup for realistic lighting, if you want something really stylistic illumination you can either "hack" your way around this with more complex materials or get down and dirty with the rendering pipeline.
  • Don't get me wrong, Unity can be a bit of a resource hog sometimes. But Unreal seems to be an expert at making even our reasonable Gaming PCs suffer. Compile times will be measured in minutes for anything but the smallest projects.
  • The way Unreal handles project files is simply not as robust as Unity's. Every time you move something, a file a redirector is created. 
  • You can't just drop a png file and use it as an asset, there's always going to be some sort of pipeline to get assets into your game. 
  • As a sidenote to the previous point, you will have to export your blender models as an fbx. Many things can and will go wrong with this process. I would write a tutorial but I found it changes a lot between versions of both programs and none of our solutions have been ideal so far.
  • C# is gone. You will be using C++. This can be a curse or a blessing but overall C++ is not as great for quickly prototyping.
  • It's not very stable. Seriously, it's not. The update to 4.9 broke transparent sprites on the UI. This is not a trivial and easily-ignored bug.
  • The huge ingress of novice game developers has made communication with the Epic team and experienced members slightly harder due to a sea of (mostly) trivial questions.

Wednesday, 29 July 2015

Chocolatey is awesome and you should use it



I've recently started using Chocolatey. While the thought of a package manager for Windows has crossed my mind (oh, my long gone Linux fanboy days), I always relegated it to something that would be too hard to maintain and work with.

For anyone who hasn't used a package manager, here's what makes it better than the classic install/uninstall babble.
  • The endless cycle of "Go to website, navigate to download link, wait, double click, click next, uncheck the 'install malware option', press next 2 more times, wait again, press finish" is gone.
  • Update ALL your software with no user input
  • Got a new machine? Run a single-line command and all your favourite programs are now installed.
  • A lot less annoying popups saying an update is available
  • I think avoiding Adobe Flash updates deserves an entire bullet point. 
So how does it work? Suppose you want to install git and Flash. Easy, launch the command line as an administrator and run this command.
 choco install Git flashplayerplugin -y 
After some time both Git and flash will be installed.

Firefox's giving you warnings that your version of Flash is unsafe?

 choco upgrade all -y 
Now both flash and Git are up to date with (nearly) no user input.

Wednesday, 27 May 2015

Unity's new event system

Despite being very poorly documented, Unity's new event system can be incredibly useful. Here's a really simple script that I keep using over and over.




Saturday, 15 February 2014

Regarding Meshes in Unity

Maybe it's just my OpenGL (1.1) background but here's a few roadblocks I've hit while doing procedural Mesh generation in Unity, along with a few tips not many people seem to know of. Some of this knowledge has been useful even outside my procedural experiments.

Quick Overview (stuff you really should know)

  • You will read this until your eyes bleed
  • Mesh.vertices contains your vertices. Mesh.triangles contains indexes to the vertices array. 
  • Normals (and UVs) are per Vertice. E.g.: Mesh.normals[i] has the normal for Mesh.vertices[i] (Blender uses normals for each face, which sometimes confuses people)
  • Different materials means different submeshes (or a new Mesh if that's what you're into).

A few pitfalls and tips

  • Mesh.uv1 != Mesh.uv (WHY AREN'T MY TEXTURE COORDINATES DOING ANYTHING?)
  • If your mesh has more than  one material, you have to use submeshes to define which area has a certain material. When copying meshes, I've found that I have to manually SetTriangles() as no other way of copying submeshes seems to work.
  • The backface is determined by the order of the vertices in each triangle, NOT its normal. If your mesh looks like it's inside out this is probably why.
  • Some of Unity's built-in shaders (namely the bump mapped ones) do not calculate their own tangents. Each Mesh has their own tangent array for this specific purpose. Unfortunately they can't be auto-calculated.
    • Blender files do not have these by default but fortunately Unity can calculate them automatically. Sadly, we don't have access to their algorithm for this.
    • Fortunately there's some code floating around that works. 
  • Don't generate a new Mesh() every time. Use the same mesh instance and .Clear() it. New meshes will get fed to the GPU but won't replace the old data there, causing memory leaks.
  • 99% of the time you can just call Mesh.RecalculateNormals() at the end instead of reinventing the wheel and calculating your own normals. As far as I know this calculates the normals based on the order of the vertices. 
  • Don't forget to Mesh.RecalculateBounds() if having decent bounds is important to you.
  • When you add a collider Unity will automatically fit it to the current Meshfilter's bounds.

Monday, 3 February 2014

What a good F2P model looks like

Out of all the F2P games I've tried, Warframe has by far the best microtransactions I've seen. So much so that I've been meaning to write this article so I know what to do if I ever find myself in a similar position. However, let me just say this is not a review, just an overview of their Business Model and why I think it's great:


An Excalibur Warframe proudly proclaims: "I have the poweeeer!"

The paid exclusives

In Warframe there's only 2 things where you need to spend money: Slots and Colours. The free currency you're given at the start can get you quite a few of either and you start out with a decent (but small) selection of colours to give your character a unique look.  Everything else has a chance to show up in random "alerts" or invasions. These events are quite common, however it might take some time until you're lucky and find what you need (I didn't say it was perfect).
You can also purchase boosters but I will get to those later on.

Purchases are permanent

No "renting" costumes or any such bullshit. What you buy is yours forever. When you're purchasing a virtual product you shouldn't have the added insult of having them fade away after some time. The mods system is also amazing and you don't lose anything by trying out new builds.

It's (always) fun

Digital Extremes is an experienced game company. The game looks great and has a lot of "crunchiness". There's a great feeling when your properly modded machine gun is blowing chunks out of the heavily armoured Grineer. Or when your saw-launcher slashes infested into (literal) pieces. All the weapons feel useful in some way (although the community swears some are considered overpowered, as some always are). The game is also based on PvE fights and doesn't have many of the issues of the more competitive games in it's genre. Even so, an experienced game company can turn their amazing game into a grindy, boring mess when trying to get the average free player to give them their money.

Defence missions are basically seeing hundreds of these flying everywhere while a Nova does all the work

No grinding

Sure there's some grinding. Without wanting to go too in-depth into the mechanics, you'll need to level your Suit and your weapons to level 30 to guarantee maximum effectiveness, but a single day's effort is all you'll need to fully level an entire set. You can buy boosters to drastically speed this up if you just want to spend a few hours levelling your gear.

There's always a new reward around the corner. This mission you did just levelled your Pistol. You can now put a slightly better mod on it. How about sticking that multi-shot you got 2 missions ago? Or maybe you now have enough nano-spores to craft that new gun... I rarely find myself looking at the end mission screen and not having anything new to fiddle with. You'll never hit a point where the game will push premium content in order to make it less tedious (I'm looking at you World of Tanks).

Weirdly enough (in the F2P industry), they're also moving AWAY from tedious farming and some extremely rare resources have been made more common or easier to obtain. Eg. : When I started out, Warframe parts used to be rare drops from bosses that you had to pick up once you killed them. You now always get warframe piece every time you kill a boss and you don't have to go around looking for his corpse in case you missed it.

Insignificant timers

Crafting guns takes between 12 and 24 hours and putting together new Warframes (classes/suits) usually takes 3 days. You can rush these for real money but, besides the 3 day wait (along with time to craft each piece that makes up the warframe), it's pretty managable. You'll most likely still be levelling your current gun when the new one's ready at the forge (I currently have around 5 primary weapons ready to be picked up).

Reaching out to the players

Warframe has patches released relatively often (every 2-3 weeks I'd say) which add new content (like new tilesets, weapons or maybe an entire overhaul of the damage system). When there's a need a hotfix will be released ASAP. What does ASAP mean? Literally 3 hours after a patch. There's also the hilarious "red text" that always precedes these releases:



In short, they tell the community what's wrong: when they screw, they work on fixing it and then tell everyone what just happened instead of compiling a changelog and running it through QA for a few weeks (I honestly envy their ability to do this and still have an incredibly bug-free game). They invite everyone in-game to watch their live Twitch livestreams so they can know what's up and there's even a reward for everyone afterwards.


Overview

That being said, here's a rundown along with some bad things:

The good:
  • Levelling/grinding is quick and constantly rewards you
  • You only need to pay if you want to. There's nothing that affects gameplay which you can't craft.
  • Decent aesthetic customization by default
  • Developers that feel like human beings
The meh:
  • I don't get why there's an extremely rare item that doubles your mod points for any object. It ensures that you only use it on weapons you really like but I really don't see why there's a weird item that can double the efficiency of any gun or suit.
  • Market for buying and selling things. Nothing to add here, it's still limited to only a few types of items and the real-money currency.
The bad:
  • That 3 day wait for crafting a Warframe. Ugh. I can take it once I have several to choose but when you're starting out, it just sucks.
  • The weird rare item that can double the efficiency of a weapon is on the "meh" heading because I don't care that much for it. But it is available for purchase with real money. The PvE nature of the game limits the consequences of this. However...
  • They have recently-introduced PvP duels. I would like PvP to remain a side-feature so the P2W threat doesn't ever rear it's ugly head but we shall have to wait and see what they do with it.
  • Getting a particular item that only drops from the Void missions can be a serious pain in the neck.

Phew that was hard to write, I kept having to stop myself from writing a review several times. Nevertheless, Warframe is quite enjoyable and I think anyone that's slightly interested in the shooter genre (or multiplayer game design) should give it a go.