Travel Schedule and Downtime Update

Technical posting will mostly be on hold starting July 19. That’s because I am getting ready for a busy travel schedule in the second half of July…

Starting with MGX and TechReady, in Atlanta and Seattle, in the next two weeks. These are internal Microsoft events so I won’t be able to post much or tweet much publically. Sorry! If I’m quiet, that’s why. I return August 2.

After that, I am speaking (!) at VGU Con in DC on August 16! If you’re in the area hope to see you there!

ETA: I was hoping to get another post out, but I gotta board a plane for a wedding. Ah, summer. See you next month!

To give you some more game tech content to whet your appetite, check out my co-worker Dave going over the Prime 31 plugins. These are the same free plugins I plan to try out to enrich my game for Windows Phone. You can find plugins for all platforms here: https://prime31.com/

sunhudstuff

Sun Run: HUD Stuff

My game more or less works now. I added an additional enemy type, a “hill” that the player can crash into. I also added a quick HUD that shows a score which increments as the game progresses. None of the things I’m showing right now look nice. The hill is just placeholdered with the “capsule” in Unity and looks pretty weird, like an old Mario World hill in silhouette. The HUD is just black text. And my startup and end screen that I’m about to show are even worse… but the time for makepretties will be later; now I just want to get things working.

The code I wrote just does a “break” when the player dies. This obviously won’t work, so I need to add some additional scenes to my project.

I have two additional scenes: Splash, and GameOver. Splash will be the scene the player sees when the game first loads up. GameOver is after the player dies.

To make sure my game sees these scenes, I have to to go File-> Build Settings, and add each new scene to the build with the Add Current button. I should see a list of three scenes.

sunhudstuff3

Notice I am working in Windows Phone mode right now. So here’s this very ugly loading screen…

sunhudstuff2

Ha ha, I’m sorry, I still don’t even have a proper title for the game. But this is just a single sprite, so later, when I have a very pretty loading screen, all I will do is replace this placeholder with my pretty screen and we’ll be good to go! A small script advances the scene. I add this script to the sprite and set “scene” to be SunScene (the primary scene for the game). Then when the screen is clicked, the scene loads and the game starts. The updated script to kill the player uses Application.LoadLevel to load up the game over screen, and the game over screen also uses a click to return to the home screen.

Stuff to do:  make prettier splash screens, make a prettier score HUD and keep track of the player’s score, maybe with leaderboards? Playtest and work on feel and hitboxes, then add some Windows Phone features and publish. When HUD and score tracking are complete I’ll upload a couple web builds. Maybe you can test for me?

sunrunhorsesclose

Sun Run: Physics

This part of the Sun Run project is the part that has taken me like, forever. Hopefully in this post I will be able to condense what took a lot of trial and error for me into some quick useful help for you.

What I would like in this game is the feeling that the player drives the horses, but needs to protect the chariot. Basically, ropy physics to make the avatar feel snake-like, so the control over the chariot is slightly indirect. Here’s the little most primitive diagram of what I’m talking about:

sunrunhorsesclose-dia

I started out with keyboard controls, but then added some mouse controls as well, so the player can use either tapping the top and bottom of the screen to move the chariot up and down, or use the arrow keys on the keyboard to move it up and down. I decided to try uploading the codes (it’s just the code for now, not the assets) to my very quiet GitHub, so if you want to follow along you can check them out there. I’ll update the commit periodically. Here’s the current version of the runner script. I’ll end up updating the code later to be sure it has proper touch control listening too. But what’s key here is that I put the code module on the front horse, and not on the chariot itself.

To make a chain in Unity you can use Unity’s 2D physics Hinge Joint. Each horse has a RigidBody2D and a HingeJoint2D, and they’re connected in a line, then parented to each other to allow the chariot to drag behind each horse. These are the settings currently on, which will probably be tweaked later (but this is already a result of a lot of tweaking…)

rigidbodyshot

RunHorse1 (the front horse) is connected to RunHorse2, and so on, all the way to the chariot itself in the back. With four horses connected this way to a final chariot sprite, the control feels pretty tight, with just a little bit of slack behind. The -.75 on the chain anchor means that the horse connects to the horse behind it with a little slack instead of directly. The setting between the last horse and the chariot is at -1. I experimented with angle limits, but I didn’t like the result, so they are off for now. Notice there’s no gravity on my front horse and very little mass. If I use gravity, the horse will just fall, so away it goes! The light mass also means it’s very easy to control. Each horse has the smallest possible mass and the chariot itself is set to 0.003. Right now I’m keeping everything very light so the control feels tight, but if I want to make things harder to control, increasing the chariot’s mass makes it drag the whole chain down and is one way of doing it.

I’ve done a little playtesting with these controls and they feel “okay,” but maybe a little easier than I’d like for things to be. Some early feedback I got was that the primitive chariot sprite has a pretty unclear hit box. I’m actually using a particle system to make the chariot burst into flames… it’s so pretty, but I fear it hurts the clarity of the game, so it may have to go. Also, I’ll need a better chariot sprite and to make sure the enemy hit boxes are clear as well. Work for next time…

battlenetworkhome

Microsoft Startup Ventures Event

Hi everyone – I’ll get back to game dev blog soon, but first a word from our sponsors:

It wasn’t very long ago that I heard the phrase “The Internet of Things” for the first time, and now it seems to be everywhere. I couldn’t quite wrap my head around it, and then someone said “It’s like MegaMan Battle Network,” and then I was like, “Oh!”

But maybe you’re already working in the Internet of Things, on some cool home automation solution that you think will change the future. It’d probably be nice to have some more capital, mentorship, and support to make that happen. If that’s you, you will want to check out Microsoft Ventures. Microsoft has had success with startups around the globe, and now they want to hear from the smartest people in home automation to decide whose startup they should support and fund. Or, more specifically:

 “Home automation is ripe for startup innovation,” said Steve Guggenheimer, corporate vice president, Developer Experience and Evangelism for Microsoft. “We are working closely with American Family Insurance to provide a one-of-a-kind experience for entrepreneurs in our accelerator. Startups accepted into the program will gain critical industry insight to build companies with the potential to have an enormous impact on our lives.”

The accelerator provides mentorship, workspace and an immersive experience focused on launching world-class companies with an eye on the global marketplace. Access to customer, partners and investors while taking no equity, no debt and no dilution. American Family Insurance, the eighth largest homeowners’ insurer in the U.S., will provide deep industry experience, important consumer insights and a wealth of homeowner knowledge that would be impossible for young companies to gain access to on their own. American Family Insurance is also offering a minimum optional $25,000 equity investment in each startup accepted into the program.

If you want more information, Microsoft Ventures is holding a meeting on July 17th at the Invisible Dog in Brooklyn, New York. Check out all the details here! https://www.eventbrite.com/e/microsoft-ventures-city-meetup-new-york-tickets-12044099225

If you have a cool startup based on the Internet of Things, and you can make it out to New York next week, consider registering for the event. It’s win-win: you could get funding and workspace for your amazing new business, and I can get Roll.EXE to bust the viruses in my wafflemaker.

Sun Run: Adding Some Runner Mechanics

I hope everyone had a good weekend! It was a holiday here, which is why I slowed down development (to work on a different project actually, but also see The Edge of Tomorrow and play Shovel Knight, both recommended) but now I’m back!

Let me talk about how I went from having some sprites to having a bit of a game…

First of all, I want to give credit to the resources that have helped me with this project. One resource that has helped me out a lot is Jesse Freeman’s Unity training, and his book, which gave me some useful code for creating enemy spawns in the game. I won’t replicate that code here, but with some info in his book, I was able to create three different spawn points to spawn enemies on the board, which will fly toward the player. The first enemy sprite is a bird drawn with basically the same method as the horse sprite. You can see the graphical representation of these spawns in this working shot here, on the right:

unity-showingspawns

After a lot of trial and error, I decided not to have the player actually move from the spot. I looked at some endless runner code that actually moved the player, but it seemed to make more sense to actually keep the player stationary and give the illusion of movement instead. Enemies spawning from offscreen to the right was one way to do it, but what about the background? I saw my co-worker Dave Voyles had a great solution for that in his schmup games:

unity-showingiso

If I zoom out of my scene and switch to 3D Isometric view, you can see what’s really going on. There’s a cylinder in the background that shows a texture that’s set to perfectly wrap. The sprites are in the foreground. The code to make the cylinder rotate on its own is really simple…

public class BGRotate : MonoBehaviour {

public float BGRotSpeed = 10f;

void FixedUpdate()
{
// rotate this
transform.Rotate (Vector3.up, BGRotSpeed * Time.deltaTime);
}
}

The transform.Rotate tells it what direction and speed to rotate. I can change the speed of the motion in Unity later, though what I’ll probably do is write a bit more script to speeds things up slowly over time (which would also have to affect the enemy spawns).

The black bars at the top, bottom, and back of the scene are destroyers. They’re used to kill the player if they crash into the ground, and destroy any birds that happen to get past the player, cleaning up the scene. This may not be the most efficient solution for cleanup, but it’s working for me for now. The code for how to get the destroyers set up is in Unity’s Live Training archive under “Let’s Make a Game: Infinite Runner.” I’m linking the whole archive because it’s some of the most useful free resources for learning specific Unity tasks that I can find. It starts out gentle for beginners and has lots of specific code examples for different problems you might encounter!

Next blog I’ll talk about the chariot motion using 2d physics, which was/still is the biggest trial and error point in the game. Want to get that feel just right…

Five Questions Article

Hi, no dev blog update yet, just a quick notice that I am featured on “Five Questions With” this week thanks to TonyV! Thanks Tony!

If this sounds different from my usual writing voice, it’s because he asked the questions out loud. I just do my best not to ramble.

And sorry Mom, but you totally knew I inelegantly tried to hide all the video games in my college luggage. Long term, I think it was for the best.

horserunning8frame-reference2

Sun Run: Sprite Strategy

For most of these dev blogs, I’ll assume some basic Unity familiarity, like someone who has attended one of my Unity Getting Started talks. But I’ll explain some specific stuff about my progress. If it’s a little too basic, or if I go too fast, let me know by giving me feedback in comments or on Twitter. (Don’t be alarmed if your comment doesn’t appear right away; I moderate.)

Making a game requires design, playtesting, and lots of stuff people are confident they’d be ok at doing. But making a game also requires three things that are intimidating in various degrees: Art, Code, and Sound.

Sound is my weakest link, so I always have to Phone a Friend where it comes to that, and I’m sure this game will be no exception. But for now I’ll talk about Art and Code…

The Unity Asset Store is a good way to get both of those things, if you want to go looking. There’s lots of useful developer tools, plugins, and art there.  I just downloaded Unity-chan for kicks. But… I don’t actually like to use too many pre-built assets in my games because I like to have more control over the art and I don’t like my games to look too stock. So, custom art all the way.

My Unity project is actually set to 3D. You can organize your project folders however you want, but after some trial and error on this project, I find it easier just to group like things in like folders like this:

unityprojectfolder

Sorry it’s small – click to embiggen. Other people like to group things by what they are, so I might put everything to do with the horse in one folder and everything to do with the bird in another. Shown here is my sprites folder. Normally when your Unity project is set to 2D, any texture you import will automatically become a sprite. But my project is actually still set to 3D, so all I have to do when I import something if I want it to be a sprite is change it to a sprite in the inspector:

unitytexturetosprite

Robot Unicorn Attack is probably my favorite endless runner. Of course the importance of the catchy theme song and the design can’t be overlooked, but I think one reason it works so well is the graphics. There’s something about a running horse that’s super graceful. It totally delights 12-year-old-me, still living in my brain clutching her Lisa Frank Trapper Keeper. Fortunately, a childhood full of drawing racing ponies in the margins of my notebook during study hall left me well-prepared to sketch out this sprite:

horserunning8frame-reference2

The background of this is actually transparent – I just dumped black in there to make it more visible on the blog. I also shrunk it down some for the post but you get the idea. Now that I look at it like this, the bottom-left frame is still feeling awkward to me, so I’ll probably fix it, and there’s a liiiittle bit of a ‘shake’ where something isn’t lined up right. But after importing a sprite into Unity, if you change it in the folder in the project, it will update in the game, so I’m not really stuck with it.

This sprite looks really intimidating to draw. Actually it’s pretty easy, though, and if you’re just getting started with frame to frame animations, it’s hard to go wrong with the run cycle on a horse. That’s because a) a horse run is pretty uniform, so you don’t have to worry too much about giving it individual character like you would with a human run cycle, and b) there’s so much useful reference available of this cycle. I really like the famous Muybridge photo series, which you can easily find with a web search, but any web search for “running horse reference” gets pretty good result pictures.

eadweard-muybridge-horse

My sprites aren’t identical to this sequence but sketching it out is pretty easy. I used the pen tool in Photoshop, and simply copied the key frames of a horse run, tweaking them slightly and trying to get the horse shape to match previous frames. I used different reference photos for the tail, which I then adjusted to move up and down with the body. It’s not a hundred percent realistic, but since my horse is flying, I never moved the body at all.  I just drew the head and body on a separate layer and only redrew the legs and tail in every frame. That way the size of the body is consistent and it’s easy for a player’s eye to track. I also choose Photoshop because it’s where I’m most comfortable, but if you like free tools there’s InkScape (which is like Illustrator) or GIMP.

Drawing with the pen tool means I can set my sprite to be any size, but I’m using 1024 sprites for now and I’ll play with the resolution later. (If in doubt I find it best to start with a really high rez and then optimize down, unless I’m going for a pixel art look.) So my sprites are actually pretty huge. I also have to set the sprite tool to Multiple with a sheet like this, and then click on the Sprite Editor button to slice it up into individual sprites.

unitytexturetosprite-2

Here’s what all those sprites look like after using the Sprite Editor to break them down:

unitytexturetosprite-3

They have numbers on them, since they’re set up as frames, so if I select all the sprites (not just one) and drag them into the stage, Unity will create a new animation. I wanted to make an animated gif of it, but it would take longer to do that than it does to make the animation in Unity, so I’ll post some videos later of the whole thing in action. That’s all for now. Good luck if you want to draw cute horses!

 

sunrunhead1

New Dev Blog: Sun Run

Happy July!

I’ve been working on a new game project that I want to show a few shots of. I was originally going to do this game for the PDJam, or Public Domain Game Jam, but I completely ran out of time in the weekend. So I tabled it, but I’m hoping to release it anyway sometime this month with better polish and some Windows Phone integrated features.

I’m calling this game Sun Run for right now, but that’s just a working title in the Unity project and I’ll probably change it to something a little bit zippier later. It’s based on the Greek myth of the chariot of the sun. Maybe you know the story: the sun is actually a chariot driven by spirited horses, which carry it across the sky every day. Once the god of the sun, Helios, had a son, named Phaethon, with a mortal woman, and this half-god young man decided he’d like to drive the chariot too. Helios said only a full god would be strong enough, but he finally relented and decided to give the boy a shot. Phaethon failed spectacularly, so now you can experience that spectacular failure, in game form! It’s highbrow, but it’s also wacky.

At the heart of the idea is a pretty basic hybrid endless runner/schmup setup with the extra monkey wrench of ropy chariot physics, and an aesthetic based on Greek urns. I chose this look because it’s simple to execute but looks unique and cool. Here’s a work in progress shot:

sunrun1

Pretty basic, but I’m going to fill it out over time. I hope the particle effects can stay, but I’m debating how much they harm visibility and performance so it’s a tradeoff.

A few things I’m doing with this game that are new to me:

  1. Using the 2D physics in Unity. I’m pretty comfortable with the 3D tools, but the 2D physics stuff is mostly new to me. I’m actually developing the game in 2.5D, partially because 3D makes me happier but also because I’m going to use some 3D tricks, which you can see later.
  2. Coding in C# – I’m more comfortable with JavaScript, but I’m challenging myself to do a C# only build.
  3. Using some of the Windows plugins from Prime31 to make the game more Metro-friendly.
  4. (Maybe) using NGUI as the GUI solution – I’m still working out if the updated GUI features on Unity will be out in time to suit my needs.

So this is a learning exercise for me, but the game is simple enough that maybe it’ll be a learning exercise for anyone reading, too.

Check back soon and I’ll walk you through the process of how I create my sprites, and some resources that are helping me with this project!

NGUI on Unity Store

A common question I got during my recent Unity demos is what is a good way to do UI in a Unity game. I admit I just did the UI within the main engine, but it’s not the greatest. Recently a co worker pointed me toward NGUI.  It’s a more robust solution for Unity GUI development. I’m going to post a tutorial soon, but, I mention it now because NGUI is Unity’s Deal of the Day and the paid version is 66% off today only. I’ll stick with the free version for my writing though so anyone can follow along, but if you’re interested, pick it up!

Amanda Lange's Blog