Saturday, December 3, 2016

Learning Unreal Engine 4

Eight or ten years ago, I looked into UDK (Unreal Engine 3) as a potential tool to use for research and teaching of game development. I didn't get very far into it, though, in part because it required rather arcane use of C++, and most of my students don't know C++ at all. Toward the end of the Summer, though, something reminded me to look again at what is now Unreal Engine 4. In particular, I was reminded of two facts: it is now free to use, and it incorporates a visual scripting language—Blueprints—that can be used in addition to C++.

I spent just a few days before the semester started diving into UE4, and I decided to invest a lot of my "research time" this past semester in learning it. I hit something of a milestone two days ago, and I proudly posted on Facebook. A friend asked for advice on learning UE4, and so I decided to write this blog post to provide a few pointers. When I first began this adventure, I started a document into which I intended to keep a running tally of what resourced I used and what I learned from them, with an eye toward being able to reuse these in planning a future game programming course around UE4; the truth is that it quickly got too chaotic to be easily tracked down. Still, I think I can provide some breadcrumbs.

Let me point out too that my first goal was to build a simple clone of Every Extend (the precursor to Every Extend Extra, which every Google search seems to want me to find instead). I love Every Extend, as one can see from my old research project EEClone, and whenever I am learning a new game development environment, I start by recreating Every Extend.

I began by turning to only because so many of my students have told me that it is useful. I have free access through my university, but I had never used any of their videos before. I got through some of Craig Barr's training materials, but I found them much too slow for me. I suppose it gave me some big-picture ideas, but the pace was painful. Looking over Lynda's selection, it looks like they've targeted artists and level designers with their videos, not developers, so maybe I just had bad luck on this one.

Via a search that landed me on the Unreal Wiki, I ended up on a YouTube playlist on building a 2D Sidescroller using Blueprints. This was more of what I was looking for: taking a simple game and implementing it using this behemoth of an engine. It was a simple click from this playlist to finding the official Unreal Engine channel on Youtube, which has a wealth of video tutorials. My favorite series here for wrapping my head around core UE4 tools and workflow was the endless runner series.

This was about the point where I felt armed to really get into making my Every Extend clone, but I quickly ran into that imposing barrier between watching someone make something and actually making something. Truly, I thought I had a good grasp after watching these videos, but I found I still really didn't know how to do some essential things, like put a camera where I wanted it. This Pong tutorial was really helpful for essentials like a fixed static camera, custom keyboard input, and turning BSP brushes into simple meshes. Working on my learning project, I needed an event dispatcher to deal with chain reaction explosions, and this video helped me make sense of them.

It was around this time that a few things happened. First, my other professional responsibilities started eating up more of my time—particularly, travel to two back-to-back conferences (Meaningful Play and NASAGA). Second, my project hit a bit of a hurdle in terms of my desire to have a fixed play area. I had quite a bit of trouble trying to get my HUD and play area synced up so that the actual playable area would be a square centered in the screen. I ended up not touching UE4 for a couple of weeks, and in fact, I never did go back and try to fix this problem. I suspect that this beginner project was so rife with kludges that there were a lot of factors making it difficult to proceed. That's OK, though, since the whole point was really learning, not production.

Coming back to it a few weeks later, I had a concept for a multiplayer game that emerged from my game design course. This inspired me to look into the multiplayer support in UE4—another key feature of an engine that, if I could learn it, could save me a lot of effort in future work. When my team created Children of the Sun in 2013 using Unity3D, I would describe using that networked game system as "a bad time." My initial readings on UE4, though, made it look much more like what I would like to have. Unfortunately, I stopped keeping track of specific resources I used here, but I can tell you that I did much more targeted Google searching (spending a great deal of time on the UE4 forums, wiki, and official documentation) rather than binge-watching YouTube videos. That is, I had a good understanding of the actor, controller, and components model, and so I could focus more on network replication and RPCs. This video series introduced core terminology, and I bookmarked one particular forum post about Blueprint networking that is amazing, but I think you need an UnrealEngine account to view that link.

Once again, getting some simple things to work took a very long time, but that's because I had to shape and re-shape my understanding of UE4's networking model. Finally, after countless hours of fiddling since the end of Summer, I got a very simple demo running, which you can see below:

If you're a gamer and not a developer, you're going to be disappointed. Let me explain what's going on here and what it represents to me, though. First, I have a custom player controller and pawn such that the pawn follows the mouse; the farther the mouse, the faster the movement. This is done by tracking the mouse position client-side and sending that position to the server. The server handles all the physics of turning and then it multicasts the pawn position to all clients. (The pawns were originally pyramids, but I couldn't distinguish the front from the back, so it was hard to debug the mouse-movement controls. Like a good programmer, I found some starter assets with more clear front and back, and hence the chair.) The server is also spawning one new gold box every second, and when any pawn hits this, an explosion particle emitter is spawned at the point where the box was.

Conceptually, it's about as simple as a multiplayer experience can be, but again, to me it represents tens of hours of effort in understanding something new, and I'm happy with it. Unfortunately, being so late in the semester now, I am not sure that it's worth my completing this prototype either. I had hoped to make something to show my game design students, but instead I just barely got the skills to build this tech demo. Still, I may push forward to the next step: the actual game concept is an asymmetric multiplayer game, and I would like to test my own understanding of whether I can show completely different player experiences to different clients.

Thanks for reading! It's kind of a brain dump, but I hope there's something useful for you here. If you have some favorite sources for learning UE4 or any other feedback, please feel free to share them in the comments!

No comments:

Post a Comment