The Other Sky Alpha – Technical Reflection

26581-shot1

You can play my jam entry for Ludum Dare 30 here: The Other Sky

This game was a semi-ambitious idea, but I generally enjoyed developing it. One of the most important things to implement was for the first person controller to be able to support flipped gravity.

I tried to get this working with Unity’s CharacterController, but it wouldn’t be feasible for my purposes. Unity’s CharacterController only works best assuming gravity is always pointing down (with respect to the scene’s world coordinates). When gravity flipped upside down, the CharacterController would not consider itself grounded, even if it landed on a flat plain.

To remedy this and other problems with gravity, I looked for a custom alternative to CharacterController. I found something on Unity’s community called RigidbodyFPSWalker, which acted like a character controller but had Rigidbody properties. The fact that this script didn’t require Unity’s CharacterController allowed me to customize the behavior of things like gravity more easily.

RigidbodyFPSWalker does not support the flipping of gravity automatically. I don’t know of anything out there that does. So I implemented the gravity flipping functionality myself by modifying RigidbodyFPSWalker.

Unfortunately, I spent so much time implementing and tweaking gravity-flipping that I was not able to have too much time making interesting levels for the game. If I continue making this game, I will definitely make interesting puzzles and make gravity flipping a very important mechanic.

Advertisement

BlockDodger – My Second Ludum Dare Post-Mortem

Image 003

You can download BlockDodger for Windows on its Ludum Dare page, or watch a quick video showing the gameplay. It also open-source, so anyone can see the inner working on Github.

You are a green block that must dodge red blocks by either moving around or shooting blue bullets. You can only shoot one bullet at a time. The game goes on forever until you lose or quit.

The game is really simple because it was made in C++ using Visual Studios 2012 and OpenGL. Before the 28th Ludum Dare started, I was working on a graphics wrapper that was an object orientated enhancement to the OpenGL tutorials at open.gl. You can download the graphics wrapper in a zip file here.

The libraries I used for the graphics wrapper and the game include GLM (for vector and matrix math), GLEW (for OpenGL extensions), FreeImage (for loading texture files), and SDL 2 (for windowing and program management).

I’ll keep this brief. These are the things I am proud of with this game:

  • I made a GameObject system that makes it easier to create entities in the game with common properties like position and color. Each GameObject also has an Update and Draw routine, which are called by a GameObject Manager (called GameObjectCtrlr in code).
  • The graphics wrapper I mentioned earlier (in code it’s called GraphicsCtrlr). It makes using modern OpenGL functionality (OpenGL 3 or greater) much easier and a little more object oriented. The alternative was to have a bunch of procedural function calls but that would be infeasible for drawing multiple objects.
  • I made a little wrapper class to basic SDL functionality called ProgramCtrlr which really cleans up the main function.
  • Actual game logic gets a class of its own (called GameLogicCtrlr). The good thing about this is that it prevents another manager class such as GameObjectCtrlr or ProgramCtrlr from having too many responsibilities.
  • I also made a really simple collision detection algorithm that treats the blocks as spheres and uses the squared distance. Using the squared distance prevents the computer from using square root functions. Both of these features make collision detection relatively fast.
  • I learned a few tidbits about class design and a lot of intermediate C++ concepts while making this game. Concepts I dealt with include friends, static members, polymorphic storage of objects, statically allocated singletons, a user case for protected virtual destructors (they’re usually public), dynamic dispatching (using virtual functions), and other such concepts.

These were the things that gave me trouble:

  • My texture management isn’t the most versatile implementation, so I had to hack a temporary solution to choose different textures.
  • SDL’s event system is currently implemented in my code to process one event at a time. Because of this, the controls are very bad (you can only use one key at a time). I did not have time to find a solution.
  • I was encountering several access violations when iterating lists because of semicolons that were accidentally placed right after the for-loop header. (ex. for(...); {}) The compiler never gives a warning about this. Took a few hours to find out.
  • It took me forever to get my head around random numbers and time functions in C++. It limited my “level design”.
  • My current implementation for resetting the level involves too much cleanup.
  • An object pool would have been very useful for the red blocks, but I didn’t have time to implement or use one.
  • I should have implemented factories for GameObject, but didn’t have time to.

That about wraps up my experience in my second Ludum Dare jam. Thanks for reading.

**Update: I made a slightly better version of BlockDodger with better controls and interesting spawning pattern.  It’s avaliable on it Ludum Dare page, or download the zip directly.

The Motivation behind XboxCtrlrInput

XboxControllerThe motivation to make XboxCtrlrInput came about from a problem I’ve encountered a few times in Unity3D.

It started with my team capstone project, Fortress Fiasco. One of the important features the team wanted to implement was local co-op play with multiple Xbox 360 controllers. I remember the programmer in our team who was implementing Xbox input was complaining about how awful Unity is about handling multiple joystick input. And he’s not the only one. I looked into his input code and realized that Unity was probably treating joystick input management as an afterthought. Of course I love using Unity, but I think Unity should improve the handling of multiple joysticks.

Flash forward to my Ludum Dare entry 10 Seconds In 10 Seconds, I wasn’t thinking about multiplayer at the beginning of its development. I did implement joystick input with an Xbox 360 controller, but my focus at the time was to make a single player game. Joystick input with just one joystick isn’t terribly hard with Unity. Towards the middle of development, I realized that it was possible to make a multiplayer version of the game because it became a top-down duel. I had to decide between either an AI opponent or a human-controlled second player. I didn’t have two Xbox controllers at the time so I chose to tackle with AI.

When I submitted my game on Ludum Dare, I got a lot of feedback saying that the game would be great with multiplayer, and I agree with them. Considering the control scheme of 10 Seconds In 10 Seconds, I thought using multiple Xbox controllers would be the best way to go, instead of having two players share the keyboard. Since I released a Mac, Windows, and Linux version of the game, it only made sense to me that a post-Ludum-Dare version of the game should continue to work on all those platforms with multiple Xbox controllers.

I know it sounds a little naïve, but I always figured that one of the goals of Unity was to allow people to develop games they can release on multiple platforms. Ideally everything should work on multiply platforms, including joystick input. It’s obviously not as simple as it sounds.

There are two major problems you have to face when implementing such a system. First, you have to get button mapping and axis mapping to “just work” on every operating system. For that, I won’t put much blame on Unity, since that’s a platform-dependent ordeal. But I will put much blame on Unity for the second problem: multiple joystick input support is lacking and difficult work with.

There appears to be a few attempts that exist out there on the internet to try to solve this problem, but none of them are perfect. Somebody with the domain name “uberdruck” showcased a web build that seems to be pretty good at handling multiple controllers, but uberdruck does not explain how the demo’s input system works. It’s only useful as an observation for what is possible. Deciduous Games made a C# input wrapper for Xbox controller input. It’s similar to XboxCtrlrInput in terms of being a static class, but the input mapping was implemented with Windows in mind, and thus will not work on other platforms without tweaking it. The last and most popular solution was a Github-hosted project called XInputDotNet, which is an XInput wrapper to allow XInput to work on .NET and Mono frameworks. This allows XInput to be used in Unity, which will allow for much better Xbox controller input. Only problem is that XInputDotNet relies on DirectX, so it will only work on Windows.

My goal with XboxCtrlrInput is to make a C# wrapper for Unity that makes it easy to get input from Xbox 360 controllers on multiple platforms (Mac/Windows/Linux). The included C# class XCI should be interfaced in the same way as Unity’s Input class. It sounds like a lot, but I’ve made fair progress. I invite anyone to contribute to the project on Github here. It’s free, open-source, and public domain, because I think Xbox controller input should “just work” with Unity. If you want to know the current issues about getting the input to work, be sure to take a look at XboxCtrlrInput’s Issues page on Github. If you don’t use Github, you can download a zip file containing the latest code from Github. Demo project included requires Unity 4.2 because I make use of text asset serialization (which became a free feature in version 4.2).

Ludum Dare 27 – Postmortem

Image 007

[This was cross-posted from Ludum Dare.]

This was my first Ludum Dare adventure and also my first game jam. I usually avoided game jams because I was under the impression that you must suffer sleep loss. Funny, I found a lot of Ludum Dare advice saying to get a good night’s rest, but that’s besides the point.

My best impression with Ludum Dare was the wonderful community here. There was a lot of positive energy, which I don’t usually see on the interwebs. I would like to thank everyone for making such a wonderful community of game developers and for making this game jam. And thanks to everyone who played my game. I was surprised by the amount of people who liked my game!

The game can be played here. Video here.

Image 010

Continue reading

How to host a Unity web-game with Google Drive

[Update Jan 2017] Google stopped hosting links from Google Drive a while ago, so this post is basically useless now.

[UPDATE: Dec ’14] Hosting Unity games on Google Drive has recently stopped working (at least for me). Even when I follow Google’s new instructions for getting the hosting link, Unity games don’t load from Google Drive. This includes games that were previously hosted and used to work. So I’m afraid it is no longer possible to rely on Google Drive to host Unity games. Your mileage may vary.

[Update: Jan ’14] It seems Google thought it would be a good idea to change Google Drive’s interface a little bit. So I updated the tutorial to match the new interface.

In this tutorial, I’ll show you how to host a game made with Unity3D on Google Drive. This tutorial assumes you know what the Unity Web Player is. I have seen a few results on how to host a Unity web-game from Dropbox, but I personally couldn’t find one about hosting from Google Drive. I wanted to host a Unity3D game from Google Drive to present to the Ludum Dare game dev competition.

Continue reading

Going to participate in Ludum Dare 27

This is going to be the first time I participate in the Ludum Dare game dev competition. My hope is that I’ll make something at least decent in 2 days. This will be a test of productivity.

Here are the tools I’m considering:

IDE: Game Maker Studio or Unity 3D, depending if the game will be 2D or 3D.

Language: GML or C#, depending on which IDE I choose.

Audio: Wavepad, BFXR, or FreeSound.org

Music: No clue…

Graphics: Game Maker’s sprite editor, Hexels, Paint.NET, or something else.

Planning: 53 Paper for iPad, and a whiteboard 🙂

To all of those participating in Ludum Dare 27, best of luck.

Follow my progress on Twitter.