April 12, 2011

Visual Scripting and Coding for Games

Recently a new visual coding extension/component for the Interactive Content and Game Development platform Unity (my engine of choice) has been announced. It's called uScript and its promotional videos are quite enticing. I've been using Unity for years, coding some C#, and since its beta I've been using Playmaker extensively. I've also checked Antares Universe, a competing component to uScript, although not to the same extent. So I'll make a quick rundown of not only the advantages of the tool but also how I see the whole situation involving OOP/coding, visual coding and FSM editors for game development - from a designer point of view with some solid coding background. Hopefully this is an interesting and mid-ground perspective that might interest some of you.

- OOP (Object Oriented Programming). Encapsulation and Properties are great, inheritance and polymorphism suck - for designers trying to read code at least. Having to read cold lines of text is already sufficient to pull a designer's mind away from the code, now having to keep multiples text files open and hopping back-and-forth among them just to understand exactly what a piece of code is supposed to do is something that, even as someone with a degree in the area and used to OOP underlying concepts, I personally despise. If you're used to notepad or notepad++, forget it, things become extremely hard to understand and usage is very susceptible to a plethora of bugs as you struggle with function names and definitions which are "somewhere else". To properly code with OOP you're pretty much *forced* to use Visual Studio and preferably Resharper just to understand what's going on, and as much as coders tout it I still find those solutions awkward and ineffective to fully grasp the power of object orientation. I find I can fragment (factor) code chunks much more while visualizing it much better using Playmaker than with pure Visual Studio + Resharper (and/or Visual Assist X).

- Visual Coding (Kismet, Antares, uScript). First and foremost, let's get something straight: if you don't know how to create a flowchart to describe game logic you're not a real designer, you're like a writer with good ideas that don't necessarily need to be feasible. So, supposing you are a designer, what's left to do? From a designer/developer PoV, I want to be able to "transcribe" my game logic flowchart to the computer, setting up commands and parameters with drop down menus to get the right fields, instead of typing a name and doubtfully hoping it's the right property or variable. VS/Resharper already gives you that possibility, so all that's left is to know what's the correct syntax to get loops and routines working as we want. Visual Assist does have code snippets that help a lot with this. So, supposing you have the right tools and don't try using the harder OOP concepts, you can describe your logic inside Unity quite easily. That's why some people make fun of Visual Coding claiming "it's already too easy to code in Unity". What they don't realize is how easier it is to create and visualize high-level and complex logics with a visual tool, due to their frequently non-linear and parallel nature.

That said, whenever I see some "real production" example of Visual Coding only one thing comes to my mind: Graph Maze. I've yet to be proved wrong (and that's not even possible since it's completely subjective) that coding something in Visual Studio + RS/VAX isn't easier than assembling the same logic in Antares Universe. Existing Visual Coding tools don't "scale up" well, when that should be specifically their number one advantage, helping the dev have a higher level control of what's happening and when. Too many games nowadays work okay during Prototype stage and fail to become real games simply because they've been built "from the leaves to the trunk". Developers focus too hard on getting the core mechanic(s) of the gameplay prototyped and fail very hard to integrate it smoothly into a higher level control of the gameflow. When that happens iterative development becomes prohibitive since you haven't planned for scale and modification. It's like trying to define a basketball game starting from the weight and size of the ball, instead of from the size of the field and number of players. You might eventually make it, but it's completely upside-down. In that critical aspect the current visual coding tools approach doesn't help at all, since it's mostly focused on small-scale behavior which is more adequate for traditional, linear coding.

- Visual Scripting (Visual FSM). Finally, there's the concept inherited from process engineering, of Visual composition of Finite State Machines. That's what playmaker uses, and it's definitely a game changer for game developers for the way it makes them think on a higher level and practically "teaches" them to compartmentalize their logic - low level logic blocks in linear text code fashion (actions) and high level logic in non-linear visual blocks (states). The way Playmaker encapsulates and present those actions in each state is ingenious, the more you work with it the more you feel like that's how an OOP editor should work. Nevertheless, it's a paradigm shift, takes some time to grasp, yet the more developers get used to that new way the more they'll realize how superior it is to the "old way". That's not to say that specific tool it's devoid of flaws though, it still lacks some nested/subFSM entity to better encapsulate tiny dependent states and clean up the view of larger FSMs, it lacks some more intra-state algorithm-ish actions (which, although demoted by the author for breaking the concept of FSMs, can be quite handy when used wisely) and better visualization tools. For instance, there's no way to open two FSMs side by side right now, so for any larger design you'll definitely want to use some pencil-and-paper or visio-like tool before implementing anything in PlayMaker. There could be more helpers like event/transition shortcuts (although it has 'global events' which can be used for that) and the ability to selectively turn some transition lines to circuit and others to bezier - currently there's only a global setting for that.

I'm not afilliated with Hutong games in any fashion by the way, but in my opinion if you can only afford one visual logic plugin for Unity, Playmaker is the right option for any serious Unity developer. If you want/need sidekick products to help it as action-generators, great, but really consider checking Playmaker's built-in action code samples, how clean and readable they are - 'look ma, no polymofo-whatever'! Trying your hand at a bit of copy+paste coding shouldn't hurt, not to mention the public actions library is only going to increase as time goes on.

Now, not saying I'd expect that to actually happen, since I know how hard it is, but if uScript has a function to convert its logic graph to standard C# code ready to be used as an action.. I will fricken buy this thing

March 04, 2011

"Messiah's Crash Course" Video Tutorial Released

Got 40 mins? Then I can show you how to kickoff with the amazing 3D render and animation package, Messiah Studio, which has just dropped temporarily in price from US$399-599 to US$10-40 (!!) in the remarkable "Dare to Share" promotion by its developer, pmG. This made the relatively unknown yet great software win many adoptors, but that ain't no good if all this new people hasn't got how to learn it quickly and easily. So I've decided to jump on the bandwagon and create three videos (totaling 42 mins) showing some of the very early steps when running the software the first time and learning its ways as quickly and objectively as possible - a crash course.

Instead of repeating what's already explained in the many videos available on pmG's site (, like how to create and tweak a bone deformer or how to use the MDD file format, in these videos I've tried to fill some of the gaps for Messiah newcomers. There's also a clear focus on actually bringing in animation and deformation data from Messiah to other 3D packages, showing how Messiah can, with its recent FBX (Filmbox) export option, smoothly integrate with most other 3D applications. I show Lightwave and Maya import workflows in the videos, but the same principles apply to MotionBuilder, SoftImage and any other software which accepts the almost-ubiquitous Filmbox file format.

It's worth mentioning that the weight map creation from Messiah's procedural weighting is nothing short of stellar, for that one feature (getting you rid of weight painting!) learning it will already provide a big boost to your animated character production speed. Being able to use those amazing skin weights with other incredible solutions like Maya's Dual Quaternion Skinning and Lightwave's IKBooster is the icing on the cake.

Last but not least I quickly go through the process of importing the Messiah-generated animation into the excellent Unity real-time engine, including the position and adjustment of cameras.

Interested already? One last thing - the tutorials are free! So run and grab it while the promotion lasts.. nah, just kidding, this will keep with its incredible low price - ie. US$ zero ;) Enjoy!

Part 1:

Part 2:

Part 3:

Project Files:

Unity Project Files

January 17, 2011

LightKeys for Lightwave 3D Released!

I'm proud to publicly release the free "LightKeys", an enhanced Navigation and Shortcuts System for Lightwave 3D. It was born out of the need of having similar navigation and item manipulation shortcuts across different 3D applications. As more and more 3D packages and applications adopt the Maya Standard for viewport navigation (Alt+MMB = Pan, Alt+RMB = Zoom), having to switch your mindset to the Lightwave style (Shift+Alt+LMB = Pan, Ctrl+Alt+LMB = Zoom) became a huge hassle for anyone using any other 3D application. To the point that I've seen many Lightwave experts using the navigation icons in the corner of the viewports, probably just to get away from the "navigation disorientation" that results when you try to switch away from the ubiquitous (and highly intuitive, as a matter of fact) Maya navigation standard.

Along the navigation shortcuts change, LightKeys also provides a production-proven shortcuts configuration set with highly increased ergonomy. Basically all the main Lightwave Layout features are accessible from the left side of the keyboard, making the software's operation much more speedy and confortable.

Here's a tutorial video that I've put up to show how to install, configure and utilize it, if you're in doubt if this is for you or not skip to the final 3-4 minutes of the video, where I demonstrate how I use it in production:
Click here to watch it on YouTube (HD)

 Screenshot of the LightKeys Tutorial Video

Apologies in advance for the accent, pronunciation and grammar mistakes, here in Brazil English is anything but a native language! :) I hope you enjoy it, comments and bug reports welcome as usual. Soon I'll be making a version for Lightwave Modeler and add enhancements to the Layout version as well.

PS.: Today is my birthday but the present is yours, LightKeys is absolutely free to use!

Update: 0.98 version released (8/27/12), with full support to modeler. Modeler config still WIP. Enjoy!

Click Here to Download