Jump to content

  • Log In with Google      Sign In   
  • Create Account

ferrous' Journal

Video and a GiF

Posted by , 19 September 2016 - - - - - - · 845 views

Last time someone asked for video/screenshots, so decided to try some image recording and uploading to youtube. Hadn't done the youtube thing before, but was fairly straightforward. Time to see if GameDev embeds video or not:


Also, here's a gif:
Attached Image


I've done gifs before, I don't think this game shows quite as well as my turn based tank game does, though here's one with an image shader
Attached Image


And as before:
Available for Android and WebGL:
Android: https://play.google.com/apps/testing/com.Ferrous.RollSwipeWin
Web: http://joshv.itburns.net/RollingWebGL/

Still puttering away

Posted by , 12 September 2016 - - - - - - · 758 views

So I still poke at my games, I just forget to post here =)


Lets see if I can sum up all the things added since last time:


Swinging Wrecking Balls
Magnets Overheat, top and bottom magnets as well.
Better tutorial message improvements
Level change message
Some image shader effects for entering the goal, and on death
The goal sucks you in now
Bowling balls


And some minor bug fixes.


Available for Android and WebGL:
Android: https://play.google.com/apps/testing/com.Ferrous.RollSwipeWin
Web: http://joshv.itburns.net/RollingWebGL/

Integrating Google Play: An Early Open Alpha

Posted by , 14 July 2016 - - - - - - · 685 views

This is my first time playing with Google Play Services integration with Unity. It's pretty early Alpha, but should still be fun to play, and I've got an integrated google leaderboard that I'd like to test out. I look forward to seeing your high scores on the leaderboard!


Here's the link:


(I should also get off my butt and try iOS, everything should work, just need to test it)


It took a bit more work than intended, the plugin has lots of steps, and there was some mystery compiler errors along the way that had to be deciphered.


I need to fix the audio, (including the audio options menu), add a way to view the global high scores without dying first, tweak more sounds. I think I want to remove the rocket turret, though if I could make some art for it instead of the placeholder rocket it might work better. And bugs of abound, of course.

Turn based Tanks, an update

Posted by , 25 June 2016 - - - - - - · 563 views

So with limited time, I decided to laser focus on just one thing, and that was optimizing my radial pathfinding. Honestly, probably didn't need to be the focus, but when you don't have a boss, or a time frame, might as well follow your passions.


So, first thing of course, was to profile things. Which is relatively easy to do in Unity, though their profiler's UI is really awful, after going about 10 calls deep, it starts to choke. And this is 100% the ui, not the recording, as it's while digging into an already recorded trace while the game is not running. I even ended up moving some of my code around to avoid the problem, which is sad.


Anyway, some easy fixes stood out. For checking a dubin's curve, which consisted of a start arc, a line and an end arc, I was checking in that order to determine whether they crossed any tiles. And well, arcs are more expensive to check than lines, and if one is blocked anywhere, the path is invalid, so I swapped my if to check the line first. I also noticed that there was a lot of memory allocations happening, and moved many of my smaller classes that were mostly data to structs. That had a consequence though, structs of structs in the crappy version of mono that Unity uses (seriously Unity, why don't you update, I also would like to use C# 6.0 features), cause a str.memcpy to show up in the profiler every time there is a copy. Now it might just be an artifact, as it's not showing up as taking a large percentage of time, just annoying that it's showing up at all.


Also, to improve memory, I moved to pooling my visited nodes. I also decided to dig into the priority queue I was using. It's Blue Raja's Queue. Which is mostly good, it just has a lot of features that I don't really need. For example, each queue node has a double priority, a long for 'InsertionIndex' and an int for the QueueIndex. The InsertionIndex is to prevent ties. You're supposed to then inherit from his structure and have your own data for the visited node.


I simplified that down to a float Priority and a unsigned int for the QueueIndex, and an int for an index into my visited node pool instead of inheriting. For tie breakers, since I always start at 0 in the node pool, I multiply my priority value by 10.0f and add nodeIndex/NodePoolSize. It's crude, and if my floats got big enough, could possibly run into issues, but that's unlikely considering the size of my navgrid. So my PriorityQueueNodes are more compact and take less comparisons when doing cascades up/down:

return (higher.Priority < lower.Priority ||
                (higher.Priority == lower.Priority && higher.InsertionIndex < lower.InsertionIndex));

Mine is:
return higher.Priority < lower.Priority
I also moved away from an array of Nodes, which contained all sorts of data about them, to simple boolean array of Open/Closed nodes. Eventually I may need to change that to something more complex, to more accurately reflect nodes that cost different amounts to move through, and to take account of different costs between Node0 To Node1 and Node1 to Node0. (aka, not just nodes, but edges) but for now, what I have is good enough. I also trimmed out unnecessary data, ie, don't keep the index of the node in the array, that's just wasteful, I also dropped keeping the position coordinate, and calculate it every time I need it, as it's relatively cheap to calculate on a uniform grid.


Anyway, so on a Deep Profile, which is really slow, I am able to pathfind across my map in about 300-400 ms in the Editor. Considering I started around 1200-1400 ms, that's a pretty decent improvement. And outside of the editor, a windows 64 bit executable is screaming fast to calculate. WebGL is still slow, I'm guessing the conversion isn't as good, and there are other oddities as well, like my camera controls don't work the same.


I'm tempted to try it as a C++ DLL and see if I get any further improvements. There would be some small benefits to doing so, and the managed to unmanaged barrier would be minimal, since it's only at the start of the pathfind.

Long time no post

Posted by , 23 June 2016 - - - - - - · 592 views

I got sidetracked by life for a while. Then I tried to integrate google play services for the leaderboard and somehow broke my Unity project. (Fun times) That kind of killed my drive. That and adding sounds, I found to be mind numbing. I don't like the sounds I have now, I find the saw noise to be too grating on the ears.


Anyway, here's a updated link:
I have an APK if anyone wants to try it on their android phone.


I also got sidetracked trying to optimize my radial pathfinder, I'll post about that in a separate thread/article/post/entry/whatever.

I should show my progress

Posted by , 16 February 2016 - - - - - - · 1,244 views

Okay, it's been a bit, I've been having a devil of a time getting a long enough block of time to both code some stuff, and update my journal. So I've been usually defaulting to just coding =)


Anyway, here's the latest webGL version.


I still need to do a tutorial / control explanation, a web based high score table, sounds, a credits page, and probably should get some real graphics, those you see are all free from the asset store. I need to double check the license on the font, I may need to swap to something else. The turrets are also a little buggy, and I want to delineate the obstacles (easy, medium, hard) so they come in a little more gradually. (There is code in there that every 5 levels, it spawns all the same type of obstacle)


I also should try making an iOS build, the Android one runs great.


Swipe / LMB + drag to create roads, coins add score + time, get to the swirly vortex to get to the next level.

The GameObject Pooler

Posted by , 06 February 2016 - - - - - - · 977 views

So another fellow was doing a journal and was a little nervous about posting code for review. It got me thinking that I should post some code up as well. (I do have a game update that I could do as well, but I'll save that for later)


Anyway, my game spawns a lot of random levels that are populated with random amounts of game objects, and rather than use GameObject.Instantiate and Destroy repeatedly, I decided to pool the objects and re-use them. I looked around online for free ones, saw someone posted theirs, but... I didn't like it, but it did give me a good base to strip out and make my own:

//This is a heavy modification of the original code found here: http://forum.unity3d.com/threads/simple-reusable-object-pool-help-limit-your-instantiations.76851/

using UnityEngine;
using System.Collections.Generic;

public class GameObjectPooler : MonoBehaviour
    // TODO:  I could probably re-work this to get rid of the singleton
    public static GameObjectPooler Current;			//A public static reference to itself (make's it visible to other objects without a reference)

    public GameObject[] prefabs;				//Collection of prefabs to be pooled

    HashSet<GameObject> prefabSet = new HashSet<GameObject>(); // internally we use this, makes it easier to programmatically add other prefabs to the pooler if we want

    Dictionary<GameObject, Stack<GameObject>> pooledObjects;  // key = prefab, value = list of pooled objects
    Dictionary<GameObject, GameObject> instancedPoolObjects; // Key = instance, Value = prefab

    public int[] amountToBuffer;				//The amount to pool of each object. This is optional
    public int defaultBufferAmount = 10;		//Default pooled amount if no amount abaove is supplied

    GameObject containerObject;					//A parent object for pooled objects to be nested under. Keeps the hierarchy clean

    void Awake()
        //Ensure that there is only one object pool
        if (Current == null)
            Current = this;
            Debug.LogError("Attempting to spawn a second GameObjectPooler!");

        //Create new container
        containerObject = new GameObject("ObjectPool");
        //Create new list for objects
        pooledObjects = new Dictionary<GameObject, Stack<GameObject>>();
        instancedPoolObjects = new Dictionary<GameObject, GameObject>();

        int index = 0;
        foreach (GameObject objectPrefab in prefabs)
            int bufferAmount;
            if (index < amountToBuffer.Length)
                bufferAmount = amountToBuffer[index];
                bufferAmount = defaultBufferAmount;

            AddPrefab(objectPrefab, bufferAmount);

            // Go to the next prefab in the collection

    public void AddPrefab(GameObject prefab)
        AddPrefab(prefab, defaultBufferAmount);
    public void AddPrefab(GameObject prefab, int startPoolSize)
            Debug.LogError("Trying to add prefab that already exists in the GameObjectPooler");

        pooledObjects.Add(prefab, new Stack<GameObject>());
        for (int i = 0; i < startPoolSize; i++)

    public GameObject GetObject(GameObject objectType)
                     "objecttype: " + objectType.ToString() + " not found in pool, did you add it to the GameObjectPooler?",

        GameObject returnObj = null;
        //If there are any left in the pool...
        if (pooledObjects[objectType].Count > 0)
            GameObject pooledObject = pooledObjects[objectType].Pop();
            pooledObject.transform.parent = null;
            returnObj = pooledObject;
        else // I am just always allow growing, TODO: Grow by more than 1 at a time.
            GameObject obj = Instantiate(objectType) as GameObject;
            returnObj = obj;

            instancedPoolObjects.Add(returnObj, objectType);

        return returnObj;

    public void PoolObject(GameObject obj)

        Debug.Assert(instancedPoolObjects.ContainsKey(obj), "Object not found in pool: " + obj.name, obj);

        instancedPoolObjects.Remove(obj); // this causes a bit of churn, but is handy for keeping track of all instances over pooled

    // Be very careful with this.  If anyone is holding any references to a pooled object, things get wonky
    public void PoolAllObjects()
        foreach(var key in instancedPoolObjects.Keys)


    private void CleanPoolObject(GameObject obj)
        //obj.SendMessage("OnClean"); // OnDisable gets called intrinsically
        obj.transform.parent = containerObject.transform;


Going Mobile

Posted by , 20 January 2016 - - - - - - · 2,353 views

Oh, updated the webgl one, that link is here: Seems to work in Chrome now, yay. But oddly, it errored for me in FireFox at first.


So lets see, since last time, I have:


Added a local scoreboard
Added some extra obstacle types
tweaked some physics
drastically reduced the time to remove a swiped brick that is touching the player, color them based on the time left, and have it fall instead of just disappear.
Added a cheesy spark effect. (not sure what I'll do with that one yet)
Added a +X to show the amount of score/time that is received from a coin. (it combos, +1 for the first +2 for the second, +3 and so on)


And I've built a win10 version, and tried it out on my win 10 phones. So far, so good. Though the high DPI on the Lumia made realize that I needed to tweak my Canvas settings, as all my text shrank down to really squinty levels. I was happy with the performance, super smooth on the Lumia 950, though that thing is a rather beefy phone, so I would have been disappointed if it ran poorly. I need to test on an android, I'm downloading the SDK right now, and we'll see how it does on my less high powered slate.


I want to look into doing Unity Ads. I'm thinking of a scheme where the player gets an additional 15 seconds to their timer if they watch a 15 second video. Which they can do once per game attempt. It was either that or something like let them unlock another player sprite, with different physics properties, but then I have to add a bunch of things to unlock. I'm a little bummed that Unity Ads aren't supported on Win 10 though. I may have to look into doing Banner Ads or something with the UWP SDK stuff


I also want to do a server side high score -- I started looking into it, but all the various editors I found for creating an SQL table crashed on install...not sure what that's about, I know my machine is a little wonky, so I may have to do something drastic like upgrade to win 10.


And I should do a tutorial like level, something with some text explaining swiping to create, and some text about coins.


I also really need to look into finding an artist or paying for some assets, or going the glowy route.

Okay, so its been a while...

Posted by , 10 January 2016 - - - - - - · 1,269 views

Okay, so I fell off the coding wagon, and found it a bit intimidating to jump back to the big TBS game. I decided I'd ease myself into it by playing around with a quickie simple game, and learn more about the process of putting it up on an app store. (Of various flavors, I might try the Win 10 store first, I dunno)


Anyway, so without further ado, here's the prototype of RollingSwipe


Firefox/WebGL link. EDIT: Also works in Edge, whaddya now, though I didn't see any UI.


Old school webplayer, best with IE: Link


A quick how to play, since I haven't put that in there yet:
Goal is to get the tire into the center of the vortex, you can do that by swiping to create ramps for it.


The coins give both score and time. When time runs out it's game over. Falling off the world respawns you at the beginning, but otherwise is no penalty.


PS. Slightly annoyed that Unity can't manage to make a WebGL exporter that works on anything other than FireFox. But then again my project might be screwed up somehow? I noticed early that I was getting a bunch of crashes outside the editor because none of my UI canvas elements had a default material. Not sure if that's something to do with setting myself up as a 2d project or what.



TODOs: Need sounds, some fancier graphics, some animated text increases, some better coin pickups, and more obstacle types.


I'm pretty happy with my GameObject pooler, I started out looking at a free one online, quickly realized it was terrible, and completely rewrote it. But it's nice in that beyond the start, there are no game objects being instantiated (unless starting pool sizes are exceeded), and everything is being recycled.

Low hanging fruit

Posted by , 20 September 2015 - - - - - - · 918 views

I updated the web player here, though Chrome I think disables plugins always now (works in IE, dunno about FireFox or Edge). But the last time I tried the webgl exporter, things were kind of funky and off. I'm not shooting to make my game as a web game anyway, but it is nice for showing other people my work. Though there's always youtube and Gifs.

So this time around, I decided to do some small stuff. I implemented clamping of the pitch of the gun, changed the gun to move towards the players targeting cursor at it's own rate, instead of just setting it to the cursor, did some smoothing on zoom / FOV, and futzed with some of the internal colliders, though I still need to go in and add the rest. Not sure how best to represent the turret ring, I'll probably have to make a set of small box colliders in a ring shape.

I need to do a cleanup pass at some point, there's some dead code, and some messy code.

Protip of the day:
Paste as New context menu from the component view....yeah, don't try to do that if the thing your pasting has a component requirement that isn't met. Crashes Unity. I filed a bug, though I'm guessing it's a known issue, seems like it should be common, right?

January 2017 »

1516171819 20 21

Recent Entries

Recent Comments