Railyard is out there

Railyard: Match-3 Evolved released for Android devices today, free for the time being.

Get it on Google Play



I’m too busy finishing Railyard, hopefully will push it to App Store and Google Play tonight. One more tutorial, shop system, couple of textures, credits (me, me, me again), screenshots and press-kit. Still not much to write about, but I’m planning a post about non-physics uses of physics engine in Unity3D. Meanwhile, here’s some random dev stuff you might find helpful.

I went on and bought Galaxy S3 for tests and deployment. Had to launch the game on it a single time to start optimizing everything.

First, dynamic lighting and shadows – had to drop those, apparently a huge performance hit. There goes my dynamic day/night system (still plan on returning it for PC/Mac/Linux versions). As for right now – I made sure the general picture is not flat with lightmaps and some fake shadows. Android – 12FPS.

Second, had to cut on geometry with LODs. If you’re on Unity’s free licence with no LODs, just cut your models, don’t let a scene have more than 50K tris on Android. iOS can handle much more, btw, especially my precious iPhone 5S. After LODs, performance on iOS skyrocketed, 30FPS on iPad 2 and Mini. Android – not so much, 15-17FPS.

Third, don’t use Unity’s built-in mobile shaders. Better grab a copy of Kenny Lammers’ shader cookbook and write your own. I completely replaced standard shaders with my own, which wasn’t really a big perf boost, but gained me 3-4 FPS on Android, which is an OK result. It’s now 20-21FPS on Galaxy S3, which is probably good, because the device is pretty old.

Fourth has nothing to do with performance, but. If you want to draw an object in front of others and achieve that with shaders, don’t use Offset instruction. On Android, it will fuck you up. Better solve that with render queue order, like, “Transparent-10” or “Geometry-20”.

Unity3D: killing them softly

I promised to write, and there’s not much to write about lately, and I’m kinda busy and determined to finally finish Railyard this week, but promise is a promise – new portion of Unity3D tips and tricks for beginners comin’ right up.

Trick #1

You need some nice visuals to kill an object in the scene, be it blown up, burnt or just shot in the head. Most basic “death” effect that leaves no traces of the previously existing object is dissolution – as seen in Doom 3 or Unreal 3 (or Bureau XCOM, not sure about that one) after shooting some bullets in some alien’s head, or in this picture of Hogwarts’ shield failing:


This effect can be achieved with built-in alpha cutoff shader. First, you’ll need a separate “death” material with a shader from “Transparent/Cutout” group, that you’ll apply to your renderer when kill sequence is initiated. Second, you’ll need a separate texture for your object with an alpha that looks like this (note, making those clouds less blurry will not look good on small objects while dissolving):


Third, you’ll need to animate the cutoff value on your material from 0 to 1.0f in your code:

renderer.material.SetFloat("_Cutoff", timeElapsed);

That’s it, you’re done dissolving your enemies. Oh, you wanted glowing edges too? That’s not beginners’ stuff, and requires a custom shader, you can read about it in this forum post.

Trick #2

This really comes in handy when you got a particle effect attached to the object you destroying. Particles got their own lifetime and just removing them from a scene in an instant is not cool. So what should you do?

First, make sure your particle systems are on separate GameObjects within hierarchy. This will let you detach them on parent’s destruction – like this (this should be called from script attached to root GameObject):

void OnDestroy() {

Now all the particle systems are detached from their parent, but maintain their position/rotation/scale. Two moments here: 1) if your particle systems are looped, you should stop them now and 2) if you stopped them before detaching and they have “play on awake” ticked, they will start emitting again after detaching.

Second part – how to avoid cluttering. When stopped, PSs still consume memory, so you have to kill them somehow after they completely done. A simple script I wrote will help:

using UnityEngine;
using System.Collections;

public class SelfDestruct : MonoBehaviour {

    private bool sequenceInitiated = false;

    void Update() {
        if (transform.parent == null && !sequenceInitiated) {
            sequenceInitiated = true;
            float destructIn = 3;
            if (particleSystem != null) {
                destructIn = particleSystem.duration;

    IEnumerator SelfDestructionIn(float seconds) {
        yield return new WaitForSeconds(seconds);

When detached from a parent (means parent == null) the script will initiate a self-destruction sequence, which length is determined by particle system if current gameObject has one, and also stops the emitter. Just attach this script to a gameObject with a particle system inside your actor’s hierarchy.

More tricks to follow, requests accepted.

Got no soul to sell

I’ve got perfect memory for games. I’ve been playing for about 28 years now, starting at the age of 7. If you’d ask me for a list, I wouldn’t know where to start, but name a game – and I tell you if I’ve played or not, and if I did, I remember enough details to pinpoint a genre.

No surprise that over the course of those years I’ve become so fed up with games, that to stir some kind of interest and make me spend more than one short evening on a game, they got to show either some gameplay novelty or some really good storytelling, or better both. That’s the reason I hate multiplayer – no novelty, no story, only hordes of annoying kids who don’t have a single idea of how to behave in a socium. And that’s the reason why, when approached with a question of favourite games in a specific genre, I’d unmistakably choose something from a pre-f2p era.

So, you designing a game? Do you want people to remember what you did, in a good way – in 20+ years? You see, there’s a fine, almost invisible line that separates games as an art or games as a sport, which both are fun and, well, games – and games as a product, sometimes so devoid of soul that the Devil himself would sell you some. It’s OK to balance the shit out of your design, spending countless hours on playtesting, simulating crazy-ass random gameplay situations. But when you start talking about “perfect difficulty curve of peaks and valleys to maximize user retention” – that’s where I draw the line.

The reason for this rant is that everybody seems to want to learn marketing, sales and shit, and nobody wants to learn how to build something that is fun and looks good.

What do you want?


Not much to tell about, except in the last week I’ve build a party game with Unity3D using only NGUI. Coming soon to iOS, Android and probably WP8, if I can figure out Microsoft’s publishing process.

Unity3D: loading external images

So I’ve been doing various tests to see if I can port Harmoniq, a project of mine, to Unity3D for crossplatform reasons. And not only crossplatform, and this is what this post is about.

You see, any heavy image processing operation written in native iOS code consumes shitload of memory and processor time. In fact, so much that I’ve been optimizing them for 3 months and still get user reports about performance and memory problems. Imagine, I had to write about 200 lines of iOS native code to get single pixel from a photo and not crash the app due to memory pressure. Now, imagine a color picker that can be dragged across the photo taking pixel samples – realtime. Unity does this with single GetPixel() call.

So, Unity pixel sampling performance is perfect, as expected, it’s gaming engine after all, it’s supposed to work with textures reeeeeallly fast. What’s unexpected is how Unity loads textures from external resources, be it web or device storage. The most common scenario is this: (code ahead)

Read More…

Kids these days

Gave a Unity overview lecture and a make-a-game-in-an-hour workshop to local students. Received questions about sales, promotion, marketing, “can game developer make a living” and shit like that. What are you intend to promote and sell when you ain’t got no game? Dimwits. One development related question from a group of fifty – that’s not why I’m doing this, you know.