Sunday, September 8, 2013

Some life updates

Wow, I was so down on myself about Ludum Dare 27, but looking at that little video in my last entry, it’s kind of cute.  I’m excited that Unity announced a bunch of new 2D stuff, including Box2D integration (which should make those rope physics simpler). So we’ll see how that plays out.

I recently got an awesome new job as a game developer at a company I have always had a ton of respect for.  This really is an incredible situation and I’m almost afraid to boast about it for fear of jinxing it.  It’s so nice to be excited to come to work every day.  I won’t share the details of my employment out of an irrational fear that I’ll say something objectionable in my blog some day that will come back to haunt me. Smile


The only problematic consequence of having my new awesome job is that I can’t feasibly work on my own independent game projects except as a hobby.  I may still work on non-game apps and that sort of thing, which I’ll post about here.  And I’m sure I’ll have plenty of demos I work on in Unity just for fun.

Sunday, August 25, 2013

In case anyone’s wondering why it won’t be done in time…

Same ol'

Well, I'm at that point in the competition at which I realize that I'm not going to get this thing done in time, having spent too much time browsing Reddit and watching YouTube videos, etc.  I can either keep working on it, or make better use of my time by cleaning my house, etc.

I think I'd rather do the latter, as defeatist as that sounds.  I don't feel too bad though, because I learned a lot about dynamically generating a rope/grappling hook using Unity's built-in physics.

I would say "next time", but I know I'll just feel the same way then too.

Saturday, August 24, 2013

Simple rope slinging

Okay, progress has been slow, I know.

But here’s the beginnings of the rope slinging, with no physics or termination or anything.  I haven’t decided yet but I may turn this game into pure rope slinging, no running and/or jumping.

My work so far

As always, I’ve been slacking, Redding, eating, walking, etc. when I should be working.  But I’ve got a little stick figure that can jump around and land on platforms and sometimes not fall through them:

Friday, August 23, 2013

Ludum Dare 27

I have a hard time fully committing to game jams these days, unfortunately.  But I'm going to give an honest stab at LD27 because I'm sick of having a trail of failed game jams behind me.

There was my entry for LD25, Indoctrination, which I shouldn't have even submitted because it was unfinished.  It was an attempt as a propaganda game for rationalism, but with such an important message I really shouldn't give it a half effort.

Then there was my entry for LD22, Loner Jetman, an homage to Solar Jetman.  I was disappointed in myself for spending so little effort on this entry (about 10 hours of work), yet at the same time I was happy to see how much can be accomplished in 10 hours in Unity.

There were other jams that I started without anything ever really materialized.

Anyway, with 20 minutes remaining until the jam, I need to quickly set up a BitBucket repository, etc. before then.

Saturday, August 10, 2013

Creating an NGUI Scroll View with a Clipped Panel

After attempting to follow the Clipped Panel Scroll View tutorial at the NGUI website, I realized that it’s lacking some information that probably isn’t obvious for beginners like myself.  It omits some crucial details, and adds extraneous UI elements that add unnecessary complexity to the example.

This rough but thorough tutorial is my attempt to fill in the gaps with an example that only includes the necessary UI elements.  Please leave a comment if you feel I need to elaborate in any areas.  I’m still learning NGUI so my solution may not be ideal, but it should be clearer than the official tutorial.

For what it’s worth, I’m using Unity 4.1.5f1 for Windows, NGUI 2.6.4 (August 3, 2013).  I noticed that the tutorials quickly get out of date as the NGUI interface extensions change.

To summarize what we’re going to accomplish, we’re going to create a tiled grid of images that we can drag left and right, which will clip when outside the bounds of the panel they’re contained within.  Spoiler alert:

1. Create a new Unity project and import the NGUI package.

2. Delete the Main Camera that appears by default.  When we create the NGUI UI, it’ll create the camera we’ll use.

3. Select NGUI->Open the UI Wizard, and you’ll see the following dialog.  Accept the defaults and click Create Your UI.

4. You should now see some objects in your Hierarchy created, which are pretty standard for NGUI UIs.

This Panel will be the panel whose bounds will clip content that we add inside it.  If you select it, you’ll see that its bounds highlight in green, and match the camera’s bounds currently.


Side note: You’ll notice that the white camera gizmo icon is ridiculously huge.  You can scale this down by clicking the Gizmos dropdown in the Scene view and dragging the 3D Gizmos slider to the left as desired.


5. While we have the Panel selected, change its Clipping value to Hard Clip from the Inspector.  This will ensure that anything outside the bounds of the Panel will be clipped.


Notice that this revealed some additional properties, Center and Size.  Change the Size property to something like X,Y (400, 100).  This will create a restrictive clipping range that will allow us to demo the clipping a little bit more easily.

6. Add a Draggable Panel component to the default Panel.  With this Panel selected, choose Component->NGUI->Interaction->Draggable Panel.  We’ll manipulate its properties a little bit later.

7. Now we want to add a Grid as a child to our Panel.  A Grid element, as I understand it, just organizes its children in such a way that they’re spaced evenly.  Select GameObject->Create Empty to create a new, empty GameObject in the scene.  Drag this GameObject to the Panel to attach it as a child.

Rename this object “Grid” for clarity, and with it selected, choose Component->NGUI->Interaction->Grid to add the Grid component to this object.  We’ll discuss the UIGrid component’s properties a bit later.

8. Next we’re going to add children to the grid, which will be the images that we’ll scroll left and right in and out of the clipping region.  Specifically, we’re going to add one item as a child, configure it properly, and then duplicate it several times to create each grid item from a template that’s configured exactly as we want it.
First, let’s create a Sprite object as a child of the Grid.  Select the Grid object and then choose NGUI->Create a Sprite.  With this Sprite object selected, you’ll notice that the UISprite component is pretty bare if you look at it in the Inspector.

This is because we haven’t even created a sprite image yet, and the sprite atlas that will contain this image.  Let’s do that now.

9. Using your favorite image editing program, create an image to be the “tile” that will be repeated in a horizontal pattern, and scrollable left and right, clipped at the bounds of our panel.  This is just a sample, so create or steal whatever image you want, but let’s make its dimensions 64x64.  Here is mine:

Add this image to your project’s Assets folder. 

10. With the Sprite selected in the Hierarchy, click the Atlas button.  Since there’s no atlas in the project, you’ll see this dialog:

Click the Open the Atlas Maker button to open the Atlas Maker.  This isn’t a tutorial on how to create a texture atlas so I’ll just walk through the steps.

With the Atlas Maker open, select your newly added Texture from the Project window.  It will appear in the list of Sprites (mine is called “tile_image”).


Click the Create button and all of the assets required for the atlas will be created (Material, GameObject, and the generated image).


11. Now select your Sprite from the Hierarchy again, and this time you’ll be able to select an atlas when you click the Atlas dropdown.


Select your Atlas and your sprite from the Inspector.  If you experience what I did, you’ll notice that your sprite doesn’t appear properly.  This was because, for some bizarre reason, my Grid object had a scale of XYZ (263, 263, 263).  Why?  I have no idea.  But in any case, you’ll want to change that to (1, 1, 1).  At that point, your beautiful sprite image will come into view:


If your image is positioned oddly within the Panel, select the Grid in the hierarchy and move it to a sensible location.

12. Before we start duplicating this sprite (hold your horses), we need to configure some things on the sprite’s GameObject and the Grid.  First, click the Make Pixel-Perfect button which should force the scale of the sprite’s object to match the pixel dimensions of the sprite image.

Now, select the Grid and change the Cell Width and Cell Height properties to 64.  This essentially says: “Space each item by 64 units, horizontally and vertically”.  This matches the size of the image, so they’ll stay snugly together.  In our case, only Cell Width matters, but I like consistency.


13. Select the Sprite again in the Hierarchy, and choose Component->NGUI->Interaction->Drag Panel Contents.  This is how the UIDraggablePanel component which we added to the Panel knows what to drag.

14. You still can’t drag your image around (you can test this by running in the editor and clicking/dragging your sprite—note that if it’s your first time, you’ll have to make sure you’ve saved your scene).  In order to do this, we need to add collision bounds to sprite.  Thankfully, this is easy.  Choose NGUI->Attach a Collider.  This should create a collider around your sprite which conveniently matches its dimensions:

If you run the game in the editor now, you can click and drag your image around, both horizontally and vertically.  Neat!

15. Since we only want horizontal scrolling for our example, we need to specify this restriction.  The way we do this is by selecting the Panel in the Hierarchy, expanding the Scale property of the UIDraggablePanel component, and setting the scale to XYZ (1, 0, 0).  This prevents dragging in the Y and Z directions.  Also uncheck “Restrict Within Panel”, because we don’t need that restriction (it would spring the panel contents into the panel if they’re dragged outside).

16. We’re finally ready to duplicate the sprite.  Do this simply by selecting the sprite and typing Ctrl+D (or if you’re a n00b like me, right-click the Sprite and select Duplicate from the context menu).  Do this 4-5 times.
Note that you will still see just one image.  That’s because the new images aren’t yet positioned properly.  Positioning within a grid in the editor is not automatic.  Select the Grid object and click Reposition now.  You should see something like this:


17. Run this in the editor, click your tiled images, and drag left and right.  Voila!  You can drag the tiles back and forth, and they should properly clip when outside the bounds of the Panel.

Thursday, June 6, 2013

My future development / blogging strategy.

TL;DR: I’m going to start blogging about all the technical hurdles I encounter in my game development, along with solutions, in order to prevent hurdles from killing my motivation.

I am a pretty lazy person.  Even if I finally gather the motivation to start working on my game project(s), I’ll run into a brick wall any time I’m challenged technically.  This is probably not a good trait for a programmer to have, but it’s what I’ve come to live with as someone who wants to make games.

Of course, it’s especially worse after a long day of work / lack of sleep.  The thing is, I’m a very goal-oriented person, and I quickly become frustrated at anything that stands in the way of that goal.  I’m likely to just give up altogether if it looks like there will be a ton of hurdles in the way of my goal.

To resolve this, I’m going to try to use this blog to alleviate some of those problems.  This has helped me several times in the past.  For example, when I had a completely obnoxious coworker who would infuriate me several times each day, I started blogging (anonymously) about him, humorously sharing all the annoying things he did each day.  Suddenly, his daily offenses magically converted to “completely frustrating” to “fresh new material”.  My entire outlook was changed and his behavior didn’t evoke the same hatred anymore.

As another example, in solving various technical challenges at a previous job with little to know guidance, I found myself regularly extremely frustrated at how many hurdles I had in the way of accomplishing my tasks at work.  So, I took to blogging about all of these.  Not [just] to complain, but to illustrate the steps I took to try to solve it and the ultimate solution (with a summary for readers in a hurry).  I thought to myself, “If this was so frustrating for me, there have got to be others with the same issue.”  This simultaneously happened during a time in my career in which I was feeling pretty worthless and undervalued.  I was beginning to think that these sorts of frustrations were something that only I experienced.  So I figured these blog posts would either elicit hateful responses of “Duh, that’s totally obvious, n00b” or else reveal that I wasn’t alone in my frustration.

Thankfully, the latter happened—more than I could have imagined.  I had random posts describing how to solve annoying errors in MS SQL Server or Wacom Tablet software, and almost every one of these got responses from people thanking me profusely.  It felt really good to be that very welcome search result which solved someone’s issue.

So, with that in mind, when I run into technical hurdles as I try to develop my game, I’m going to go through the hard work of solving them, and blog about the result.  The beauty of this is that it effectively creates a new, singular goal.  Each “hurdle” thus becomes a goal in itself.

I truly hope this will help others in the future.

Sunday, May 26, 2013

Well look who came crawling back...

So, I had switched to Posterous a couple years ago as my blogging choice, but apparently they couldn't compete in the market. That's a shame, because I liked their simplicity and mobile support. Thankfully it looks like Blogger has evolved since then, and I never really minded it all that much, so with a few layout tweaks here and there, I think I'm good to resume blogging here.