December 11, 2013

Hey, this hour of code thing is kind of cool. Sofia kind of lost interest after about 15 minutes. "I'm tired of making the zombie find the flower" but I told her she could stay up past her bedtime if she worked on it more and she's game.

Let me tell you, I've totally turned around on this issue. I used to be the sort of asshole who said "there are people who can grok pointers and people who can't" - using that Harvard research as my crutch, the research that said, "Here are points where people wash out of our computer science program:"

just understanding that computers execute things one after the other - this is what Hour of Code seems like it will be really good at teaching

pointers

recursion

concurrency (which is kinda the opposite of #1. funny old world)

But just because these are the points where people wash out of CS programs doesn't necessarily mean that those people were flat-out incapable of understanding these concepts. It probably just means that Harvard's sink-or-swim teaching methods kind of sucked.

New research shows that old 'fixed mindset' kind of thinging creates self-fulfilling prophecies that lmit people. It's toxic. The problem with saying, "Why are you trying to draw? You can't draw," is that people actually believe you. We have to overcome that last-century 'you must be naturally talented or don't bother' sort of thinking if we want to accomplish stuff.

Me, I'm lucky. Coming from a supportive you-can-do-it sort of family, I just enjoyed learning how to program. I got off on it. When I discovered pointers and recursion my head exploded with possibilities. Not everyone's going to be like me, and it's going to be hard work for them to grok those concepts, but I firmly believe that almost anyone can do it if they put in the effort. And the benefits are enormous - if, for example, you're a game designer or producer, and you learn to code, you're no longer beholden to other people to make things happen. You can make a game by yourself. And you can probably get a decent-paying job somewhere.

There's another sticking point besides the four I just listed above. Someone recently told me that they've tried to learn to code, and they can work through tutorials and whatnot, but when it comes time to create something original they don't know where to begin.

Well, most coders avoid creating something original. We run a code wizard that generates our windowing app for us, or use someone else's engine, or cut and paste some code off the internet. The swinging-and-wallrunning character code in Energy Hook started with the Unity character controller as a base. Eventually you'll find you've replaced the handle and you've replaced the blade and you've got a knife that's totally yours. No shame in that. (Though there may be a few dick-swinging coders out there who do try to shame you for it. Try to ignore them.) Coders are allowed to plagiarize away their blank-page-syndrome in a way that novelists aren't.

Jake the Dog time:

Going beyond Jake the Dog, there's been research that shows people are usually overconfident when they first try to learn something. There's this curve where they think they're good, then they train some more and realize how far they have to go and think they suck, and then they actually get good and they think they're good again.

So, if you think you suck at something, you may be halfway to getting sorta good at it.

October 23, 2013

I was hosting the subversion server for Energy Hook on Unfuddle, but that got pricey after I hit the free tier storage limit. So, at the suggestion of @Kostas_Zarifis, I switched to hosting on EC2, which took most of a day to figure out but has only cost around a dollar a month.

But I'm an idiot and forgot my password and deleted the key pair file which had been lingering in my downloads directory and purged long ago. Whoops.

So I had to do this again, and was taking notes on the process as I went, but decided to reboot my computer midway because I was having internet issues, and, well...lost the notes. So, here's my best attempt to reconstruct them, but there could be some gaps. If you try this and have trouble, let me know where you get hung up in the comments.

After I have my EC2 account set up, Launch Instance

I choose Windows 2008 R2 Server.

I go to Add Storage because I know that 30 gigs is going to get used up quick (almost 20 of it starts out used by the OS, etcetera). This is costing me around $10 a month but is still cheaper than unfuddle. If you want the free SVN, leave it at the free level!

I confirm and Launch.

I generate the Key Pair.

I right click on the instance once it's running and Get Windows Password.

THIS TIME, I'm saving my Key Pair and Password someplace safe. :P

I connect with Remote Desktop and find that I can't seem to download SVN or anything.

So I go to Server Manager->Server Summary->Security Information->Configure IE ESC and turn that shit off for Administrators, whatever it is.

Okay, I can download stuff now. This time I'm going to be better than last time, I'm going to use VisualSVN Server, which has more security!

I manage to set up a test repo, (using https: and port 443) and I can connect to it from the Server, but not from anywhere else. Do I have the port wrong? The address? Firewall problems? Who knows!

Eventually I figure out to go to the EC2 Management Console->Security Groups->the group for my new instance, and add rules not only for TCP port 443 but also ICMP, so I can just Ping the darn thing and make sure I see it at all. (After I add the rule I have to remember to Apply Rule Changes.)

Now things seem to work from the client side. I cansvn ls https://my-public-ip-here:443/svn/happionlabs and see my test repo. (There was a moment of hilarity, because in trying to figure out what was wrong I turned off the https: security on the server side, which changed the port to 80 without me noticing, so I couldn't figure out why, now that I'd figured out how to open the freaking ports, things still didn't work. Haha. Ha.)

July 22, 2013

Okay - I'm going to do 7drts! That's right, I'm going to make a real-time-strategy game in seven days. And I'm going to livestream as much of it as possible just for kicks -http://twitch.tv/happionlabs (starting around 10AM today)

My design goal is to see just how short a session RTS I can make. I want it to have most of the classic elements of Dune II: harvesting resources, building factories that build units, sending units to recon, fog of war - but play in about a minute. Not sure if it'll be time-limited or survival. Resources will probably be random drops - sometimes it'll just be gold, other times advances to your tech tree or free units - to increase uncertainty, slot-machineness, replayability.

So come on over to twitch.tv/happionlabs to check in on what I'm doing. Probably be boring as hell to watch, but I kind of like the pressure of thinking there might be other eyes on me as I work.

Side note: I still plan on doing an Energy Hook update on Tuesday. There's some great new stuff in there.

July 18, 2013

Specifically, I've been using Unity's OnGUI for the UI of my game, and - if you're first and foremost a programmer - OnGUI is really nice. Every frame you're responsible for drawing the GUI yourself. You don't cache state. If one frame you don't want to render a label - for example, maybe the timer isn't running, so you don't need to show the timer right now - you don't disable it and re-enable it later, you just don't render it that frame. Next frame you decide again.

It supports a document-view model of whatever data your UI is supposed to display effortlessly. Of course, we're game makers, and we're not happy with just putting our data on the screen. It's got to be Juicy. It's got to tween in, and bounce, and get bigger and smaller, etc. Since I'm a coder at heart, no problem - I smoothstep or sine wave or whatever those widgets around with nice stateless code that takes as inputs what time it is and what time this widget was supposed to appear in the first place, and my code will usually be bug-free.

I imagine people who are graphic designers at heart and only want to touch scripts as a last resort aren't so pleased.

A while ago I decided to switch to NGUI because, to support Oculus VR, I want to be able to render the HUD to a texture and then display that floating in front of the camera. (I could have used Unity's previous UI system but decided it was time to bite the bullet and start using everybody's favorite Unity UI add-on. Everybody can't be wrong!)

NGUI is as stateful as Flash. You create an assload of widgets and keep their state around forever, turning them on and off and playing animations or tweens on them as necessary. Don't get me started about the time I tried to make this cool UI screen for a game (that never shipped) and tried to get away from Flash's stateful-ness. That was a giant rabbit hole. So this time, with NGUI, I'm not trying to fight to fight the statefulness much.

And it's curtains for me. Here's one example situation: when a player is building up a combo, and their last timeout expires, they cash in that combo and add it to their total score. To make it clear to the player, the widget with their combo score in it tweens up to the real score.

I could have the widget reposition itself every frame in code. But remembering that time I tried to go against the grain of Flash, I decide to do it the NGUI way: let's try to move it by playing an animation.

Unity animations, once played, leave the target in their final resting state. Can't argue with that, that's probably what you want the majority of the time. But not this time; we want that widget back so we can build up the next combo. (Side note: astute readers will wonder - what if you start a new combo before the widget makes it to the top? Technically, yes, that's a bug, a bug that a stateless system would automatically be protected against, because on seeing it had a recent combo it would handle it correctly, but the bug will be rare enough and hopefully hard enough to notice that I'm not going to deal with it just now.)

It actually takes me a bit of time to figure out how to reset an animation! That's a Unity thing, and the answer seems to be here.

And then we hit our state problem. The widget shoots up, resets, and continues to display for a couple of frames before disappearing. There's a mismatch between the "should I show the widget" code and the animation.

Sigh. It's not exactly a game-breaker but it looks terrible. So I'll have to fix this, but I wonder if I'm doomed to problems like this every time. The problem seems to lie with me trying to use both stateless and stateful code together.

So I throw myself futher into statefulness. I create a separate widget for the animation...call it the 'traveller'...once it travels to the total score widget, we'll let the total score widget update. Which means the data in the total score widget is no longer just a stateless 'view' of your score 'document' but ... its own thing. It can now be Wrong.

One approach I've seen to something just like this, in another game, was to consider the value in the score widget the official score. It gets away from duplication of data. When the travelling HUD element with the +15 or whatever mades it to the score, that game added it in, and that was the new official value. The way that game made the view itself an inextricable part of the game felt wrong to me.

And if I used a similar approach with Energy Hook it could easily fail - that traveller widget currently just resets if a new combo is built up. If I did it the same way as that other game, those points would never make it into the final score.

So, here's what I end up with. The GUI, even though it has its own internal state, is still very much just a view of the document, like so. Cashing in a combo doesn't trigger a state change - the GUI watches until your total score increases, and then plays a purely cosmetic animation. I could delete the GUI script and the game would continue to play and keep score under the hood without a care. Another way of looking at this design, without even considering state, is to consider the code dependencies. The UI state depends on the Game state but not vice-versa.

It works; looks good; and has been in there for a couple of weeks now and I haven't noticed any real problems.

What's the take-home here? This is a common problem with game UI's in general. This model, where it's document-view but the view doesn't completely update until after it has played its pretty animations, the communication is one-way, and all the hateful stateful event-driven crap is in the cosmetic side, seems pretty solid...

Now, I'll have no problem remembering to keep that communication one-way. But if I was working closely with other programmers on this, I'd like some way to make sure that the UI remained cosmetic. I'm not sure how I'd do that. Even if I set up namespaces it's a knee-jerk reaction for programmers to create circular dependencies at the slightest provocation - including me.

This may seem like a trivial thing to focus on, but we spend so much of our time dealing with these trivial things that should be simple. And often the least experienced coders and scripters do the UI of our games, creating systems that are a patchwork of band-aids that break when you breathe on them funny. So it's worth thinking about deeply.

July 05, 2013

This GUI bug I've been wrestling with lately was a bug for the history books. It didn't reproduce on my dev system - it *did* reproduce on my laptop, but out of nowhere that's when my laptop stopped being able to run Unity properly. I started seeing this...and it would crash when I tried to open MonoDevelop. Exciting. So a lot of building on one dev system and sending it over to the other, when my local network would let me, with its Windows groups bullshit. (Running it back and forth with a USB the rest of the time.)

Happily, shout out to Imron Alston who figured out how to repro it on a Mac, improving my iteration time greatly, and shout out to Tasharen / NGUI who had awesome support on their forums. But even when Tasharen told me how to fix the bug it still didn't get fixed. Why? Because of this block of code:

It was supposed to be CameraClearFlags.Depth, and when Tasharen told me that I went and changed it. IN THE INSPECTOR. Not in this code I'd written that overrides the inspector which I forgot about it. So I kept complaining to them, "That didn't fix it! It still doesn't work!"

Until I got lucky and finally noticed that my script was changing it back.

SO. Going forward: let Unity be Unity. Avoid having script override stuff when I can. In cases like this, pick one thing to be the default, and that's what's in the inspector, and let the code override the other one.

And I'll have an update out with the new prettier UI working in both regular and Oculus mode plus y-axis flipping soon.

March 25, 2013

I had fun playing with perlin noise and shaders to make the various procedural smoke patterns for sixty second shooter and last week brought the same tech over to Energy Hook - but before I did, I looked around the Asset Store to see if there was anything that would do the same effect. There was, but it was all at least $50 or more, and didn't feel like paying it. So I did the work - took me longer than I expected to figure out ShaderLab - and here's the result.

And then I thought, hey, I would have paid $10 for that. So why not put it up on the Asset Store and see if I can sell any?

It's not the most powerful or flexible procedural smoke generator in the Asset Store, but I'm pretty sure it's the cheapest.

Why is the Unity Asset Store so much more pleasant than the Windows 8 Store or the Chrome Web Store? Well, it's curated, so there isn't a lot of utter crap in there. (It's tempting to download every single free asset.) It's sortable by a variety of parameters (such as price.) It's easy on the eyes - partly because it's curated (there aren't infinite results splitting your attention) but partly because the graphic design is better IMO.

Submitting an asset wasn't hard - about as easy as putting an app in the Chrome Web Store - and seemingly much easier than submitting something for the Windows 8 store. And it was accepted on my first try, so yay.

I'll keep you posted how it's selling. Although I doubt one could make a living out of selling stuff in the Unity Asset Store unless it was something crazy popular that almost everybody needs, like nGUI, there's a chance it could provide decent alternative revenue if you're selling stuff that you would have made anyway for your game - then it only has to pay for the effort to get it into the store to make it worthwhile (but mustn't forget to include the opportunity cost...) We'll see.

On the technical side, if you want an effect like this and you're too poor to pay the $10, I'm here for you, since you're a valued reader of my blog. This is where the magic happens, the Cg that I brought over from sixty second shooter:

The texture it looks up into should be a perlin noise texture with different frequencies of noise in each color channel. It uses the RG channels to then look up into the texture a second time, and then blends that noise together. But it does interesting kaleidoscopic things with normal textures as well. You'll have to wrap that in ShaderLab stuff to get it working in Unity, but it should work more or less as-is in engines that use straight up Cg (like Playstation Mobile.)

Enjoy! If you buy it, feel free to ask questions right here in the comments.

March 01, 2013

Although now it seems obvious, it took me a while to have this "Aha!" moment, so maybe it's worth sharing.

At first look with Unity I thought there's not much there to build a cool title screen or front end main menu - the GUI interface and its skins give me just enough to get stuff done but the sort of fancy tweens I might set up in Flash seem out of reach.

For example, with We're No Angels, I wanted to be able to slide from one screen to the next. Using the GUI stuff to place bitmaps on the screen and position them would have been tedious.

My "Aha" moment: "Wait a minute, Unity is a whole engine for moving around not only images but meshes and whatever!"

Unity has an Animation System which has been deprecated - I sometimes feel like I'm one of the only people who ever use it, most seem to prefer to animate things directly in script - but you can do it that way too. By simply laying out a bunch of textures and animating the camera with the animation system, I was able to do this:

Those are just Plane objects with textures applied to them.

So, problems with that: that Animation system has been deprecated, apparently they're going to replace it with some sort of new hotness, but you could also animate the camera in script if you don't want to take the time to learn their fiddly Animation system.

Also, textures default to a maximum resolution that's probably smaller than your screen. When importing the textures for big screens, make sure you set the Max Size for your platform on the texture to something big enough. (Our screens were blurry at first and didn't know why.)

So, making an equipment screen for Energy Hook was easy:

That's a 3D scene with a texture mapped Cube object in the background, our jetpack mesh, and a spotlight (it's supposed to be casting a shadow on the background ... I'll figure out why that didn't work another day) - and the text uses the GUI stuff.

Anyhow, my key takeaway or mental shift: a Unity scene doesn't have to be a game level, it can be an arbitrarily elaborate front end - like a somewhat klunky but very 3D Flash. How obvious should that have been?

February 24, 2013

My main computer is a Mac Mini that I got as a gift, and I've recently begun chafing at my inability to play Windows games. I'm cheap and not crazy about clutter, so rather than buy a whole new machine I thought I'd install Windows 8 on it and dual boot. How hard could it be?

In the end, I'm pretty happy at the result - Loadout is running buttery smooth - but getting here was quite a battle. If you dare follow me into the trench, you'll probably want to know some stuff.

But the most important thing to know is that doing it this way seems to require a call to Microsoft technical support. So there's got to be a better way. But more on that later.

My go-to how-to article was this one. But it leaves some questions unanswered. First, there's the problem of not having a disc drive on the Mini. Happily, Boot Camp let me put the Windows 8 ISO file on a thumb drive and boot from there. But how did I get the Windows 8 ISO file? Microsoft doesn't just want to let me download it.

So I went to my old not-fast-enough-to-play-games-anymore-doesn't-even-run-Diablo-3 laptop and started the Upgrade process from there. That let me download a Setup program that then let me download the ISO file which I could then copy to the Mac.

Then I ran Boot Camp as normal, but am not sure what happened because I left the computer and when I came back it was on a black screen. After waiting several minutes I rebooted and it default booted to the empty windows partition. So I manually booted to the thumb drive by holding Alt (AKA Option) at the sound of the Mac boot-up chime, and it seemed to run the Windows 8 Install correctly, but then the program told me, after I formatted the Bootcamp partition, that it couldn't install Windows there because of confusing stuff involving "bios" and "efi" and various other acronyms.

I was about ready to give up there, but just for the hell of it booted back to the Mac OS, went back to Boot Camp, removed and re-added the partition, and this time when it restarted it booted off the thumb drive just fine, and after formatting the partition (Drive Options -> Format) it let me install just fine.

(Then I forgot to run \WindowsSupport\Setup.exe off the thumb drive after Windows 8 was running. So ... don't forget to do that.)

And then I installed Chrome and Steam and played some Loadout and things seemed happy.

But I hadn't actually 'activated' Windows 8 yet. I'm not sure what happens when you don't activate it, it probably simply stops running after some grace period, but when I went to try and activate it with the code I bought on the other machine it didn't work.

After talking to Microsoft support I learned you can run "slui 3" to try to activate Windows and actually get an informative error code. Mine explained that I can't use an Upgrade version of Windows to do a clean install. Ok. But then the support people I talked to (after various confirmation steps and hoops jumped through) gave me a different code to activate my copy.

So, like I said, it seems if you try to do it this way, talking to Microsoft tech support is a necessary step in the process. At least I could do it all over chat while browsing my twitter feed at the same time.

Which makes me wonder, just how are you supposed to do a clean install? It seems like the only thing you can download is the Upgrade. Am I supposed to go to an actual physical store or something? That's ... so last century.

The Games

Jamie's Bragging Rights

The best superhero games of all time Game Informer Top five games of all time Yahtzee CroshawTop five superhero games of all time MSNBCTop 100 PS2 games of all time Official Playstation 2 Magazine1001 Games You Must Play Before You DieNomination for Excellence in Gameplay Engineering Academy of Interactive Arts & Sciences

Penny Arcade PAX 10 Award Nominated for XBLA Best Original Game Nominated for XBLA Best Co-Op Game