Making a Controller Editor in Unity
As I mentioned very hastily at the end of my "Hello World" post I have a YouTube channel where I provide tutorials. The problem is I don't actually have any concrete content to back up that statement. I started a Sudoku series roughly 10 months ago and stopped working on it because my Architecture of Real-Time Systems class was taking every second of time I had at the time. That class ended up changing my perspective on building games for the better (as every single class I've taken has *eyes emoji*) because, I immediately wanted to start the series over and do it proper instead of on the fly and improvised. Doing the planning for such a small game still takes time and I keep getting swamped in work from school to actually want to sit down for a week or 2 straight and do the planning.
Fast forward to this week where I suddenly had the itch to program a system based on Robert Nystrom's example for the Command Pattern in his Game Programming Patterns book which he describes as useful for building controllers. Instead of having giant blocks of code made up of if statements checking if a particular key is pressed and subsequently executing a command such as a jump or dive, a controller object will have a series of actions assigned as variables that can be modified or reused for anything such as the player's character or AI. This concept has actually benefitted me greatly and our code at BST (Blue Street Studios) because we always program in demo and autoplay logic when the user is inactive. The main input system for the user is by touching the screen, so we need to wrap up the actions as a controller that can be used via touch input or programmatic logic.
What is really good about this design is that it isn't terribly large and the planning required is minimal. The real factor was how complex did I want to make this video. As I started working it I concluded that there are 2 types of ways to go about it while keeping my sanity, a system where the inputs are narrowly limited such as a handheld controller and a system where the inputs are numerous and outnumber the actions a user can take. I'm sure there are more, but if I start thinking about those then I may never actually be done working on this (I'm already imagining a system where the user can only use a limited number of actions from a large set and the inputs are numerous such that the user does not have to use every input). At the end of the day my goal is to persuade to viewers why the pattern is useful for designing a controller and not spend a whole lot of time covering the endless number of ways developers can spec out the requirements for the actions that the user can execute with their input device.
All in all, I am pretty satisfied with how it turned out. I think I provided enough code that can be used in any environment with minimal transcribing and also left enough open for anyone wanting to work on their own system. The link to that video is here. Source code is here. I still need more experience with making videos. It is hard covering everything I want to cover and say while also keeping pace and not taking up a hour's worth of time.
Lastly, to wrap up this post... Unreal Engine finished downloading and I managed to open it up and try to familiarize myself with everything. My conclusion is that it's a pig and the recommended specs should be followed. My machine is fairly good even though it's 6 years old now, but that's why I spent what I spent at that time. I made sure to clean up like 500 GB of space to accommodate it. I really hate that when I'm doing something the fans on the tower kick on and sound like they're running a marathon after a night of heavy drinking. My biggest issue so far was getting intellisense to work. It wouldn't work with Visual Studio 2019 Community for some reason and so I decided to pre-open Visual Studio 2019 Enterprise with great success. The latest issue is trying to figure out how to access the Transform of a mesh from a custom ActorComponent.cpp class so hopefully that shouldn't be too difficult. I found some code but the changes weren't being applied to the object, but it's probably something small that I am overlooking.
Comments
Post a Comment