I am a versatile software engineer, currently employed at a company that utilizes gaming technologies for interactive and educational experiences. My main focus is software design and implementation ('programming'). I do however also have hobby-experience doing some Blender 3D modeling/animating and designing levels for various games!

Report RSS Adventures in the world of Unreal. Part II

Posted by on

Hello there and welcome back to Metalspy's wondrous game (development) blog!

About four months ago I posted about my first steps using UDK, mainly as a preparation for my internship at a (small) game company. In those four months I have barely done any game development, or software development in general, in my spare time. A lack of time and especially a lack of energy prevented me from doing so. Last week however I got a sudden boost of motivation and energy, so I launched UDK and Visual Studio to finally continue my work on my game project. Oh my, was I in for a surprise. As soon as I exited "Play in editor" mode, the UDK editor crashed. According to the log this was caused by my own code. Diving into the code to fix the error I was met by a second surprise: the code I had written in my 'UDK beginner phase' was ugly, lacked organisation and did not allow a lot of easy expansion of the existing feature. So I decided to throw everything away (it was uploaded to a repository so it wouldn't be permanently lost anyway) and start all over. I did this with the following goals in mind:

  • Write easy-to-maintain code with a decent, modular and easily extendable 'architecture'
  • Only derive from standard engine classes, not from UDK or UT classes, to prevent having a lot of unused variables and functions
  • Apply the new code conventions I have picked up a few weeks back to (hopefully) improve readability
  • Use plenty of comments, so other (new) UDK users can easily understand what is going on (I consider releasing the project's source code in a later stadium)
  • EDIT (2013-12-28): After reading the first chapters of Robert C. Martin's "Clean Code" (ISBN-10 0-13-235088-2) the last two points above have changed to "apply the lessons learnt from reading Clean Code to make the code readable for new users and improve maintainability".

(Basically: write good software that's accessible to beginners!)

After approximately six hours of work I had set up and recreated most of my previous work (which wasn't all that much and certainly nothing special). Four months ago that took me FOUR WEEKS. This time my code was shorter, a lot better organized and easy to expand. It even changes the material of the object during the placement phase and allows the player to rotate the object (s)he is placing, which was not possible before. Working full-time with UDK during my internship certainly allowed me to gain a lot of experience! And the most important thing: I had a lot of fun during those six hours of developing. I definitely hope I won't lose this energy and motivation anytime soon so I can create a prototype of the game I had in mind!

Anyway, here are some screenshots of the current state. It's basically the same as last time, but the code that's running under the hood is way better :)

1. Placement phase

2. Result after placement phase

Post comment Comments
hugo1005
hugo1005 - - 68 comments

I'm working on a project in unity at the moment, did basically the same thing as you, I was working on a game that was going to create a procedurally generated modular level so that it would be different on every play. I spent about 3 months on this project, (In spare time so maybe 3-4 times a week for an hour or two) By then it was a complicated sprawl of numerous scripts spanning about a thousand lines, when i started running into problems they would take days to fix so I gave up started again, planned it better did more R&D and in two weeks achieved an infinitely better result, however I started coming up against numerous bugs that I kept pushing through and fixing. Once again it became more and more difficult to decipher bugs to the point of a standstill (Procedural recursive code gets complex like that :( ). So i stopped and took out pen and paper and planned again, I spent a day planning and Today working on the code, I now have a solution that is about 70% there on my last iteration in a day with a little under 113 lines of code compared to the original 1000.

Reply Good karma Bad karma+1 vote
SIGILL Author
SIGILL - - 1,157 comments

113 instead of 1000 is a very nice improvement! Is it still recursive, procedural generation code? Or did you find a way that is easier to debug? :) Because I tried some (recursive) procedural generation, also in Unity, myself and it was indeed quite a pain to get it right! And what kind of game are you building?

Unfortunately (although not really surprisingly) I did abandon the project this post was about, because one of the goals was to eventually provide a nice example for UDK beginners, but with UE4 released and available I felt it was not very useful anymore to do so. Another reason I abandoned the project was because I prefer writing 2D games for solo-projects, it's just way easier and especially a lot faster to create and handle 2D assets!

Reply Good karma+1 vote
hugo1005
hugo1005 - - 68 comments

Yeah its still procedural and has gone up to about 200 lines with the guts of this mechanic finished.
Recursion takes time to get right, complex to understand at first but essentially you are just calling another identical object and running the same script. In my case I am building a procedurally generated spacestation assualt training simulator made up of modular parts. Each module has a script attached to it to search arround it and based on that addition a new module off of it. The new module in turn calls its script to search and add new modules etc.

Probably be a while until it takes shape as a space station though, at the moment I only have 4 modules which are all the same sizes, wall, floor, corner, door. I will probably start posting more on moddb in january

Reply Good karma Bad karma+1 vote
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: