Integrating Game Creator’s Melee module with Corgi Engine and Rewired
More Mountains’ Corgi Engine has proved to be a fantastic, amazingly supported base for a 2D platformer. And with even just a basic understanding of C# scripting, I’ve been able to extend its functionality where I want.
One of those areas is melee combat. The folks over at Game Creator have put together a fantastic little combat system called, well, Melee. Only problem is that it’s meant for use with Unity 3D, emphasis on the 3D.
Melee has a pretty impressive suite of features which I may delve deeper into later, but for the moment I’m going to let Corgi handle things like hitstop and player/NPC movement. The thing I’m most interested in is Melee’s exquisite input buffering Combo Creator system.
First, I’ll need to get the Game Creator plugin listening for Rewired inputs instead of just the usual keycodes. Game Creator calls these “Igniters”, and creating a new Igniter class to communicate with Rewired is a piece of cake. A few lines of code later and we’ve got access to Rewired’s full suite of input parameters, with room to easily add more as needed.
Now that the inputs are wired up, we need something for it to talk to… and this is where it gets a bit unconventional. You see, Melee is meant to interact with the physics of a fully rigged 3D character. And I’m currently using 2D sprites with 2D hitboxes. Melee simply will not run without a 3D character to talk to.
So how can I get around that? I can’t, not really. But what I CAN do is give Melee an invisible character that’s parented to the 2D player. We’ll call it “Null.”
Null here is a fully functional mesh-less skeleton. After being set up in Unity’s Avatar creator (which forces you to parent the spine directly to the hips, who taught these guys how to rig??), I’ve got a 3D character for Melee to control. A similar setup with an mesh-less weapon gives Melee the other reference point it needs.
Now if I wanted to, I could go back and animate Null here to match my sprites’ movements to take advantage of some of Melee’s other cool features, like dynamic motion trails. I could even use Melee’s hitbox recognition at this point… but I’m going to leg Corgi handle that.
Corgi Engine is a 2D raycasting engine, not one that relies on physics. Translating the 3D physics based motion of Melee to Corgi’s 2D raycasting forces is beyond my limited programming skills, so I’ll just let Corgi’s weapon handling class take care of movement parameters.
Some extensions to said weapon handling class allow me to switch between “weapons” – attack types – on the fly. By creating an array of customizable weapons and giving each weapon its own public void, I can call them with Game Creator’s event system.
And now we get into the fun stuff. With all of that set up, I can start playing with Melee’s robust Combo Creator. The Rewired Igniter listens for button presses to feed into Null, which in turn feeds them into the Combo Creator.
Each different series of button presses yields a specific result, all queued with the exact timing I want. Melee Clips tell Melee how to execute each attack, and in my case they fire off an event that calls the appropriate void in Corgi’s weapon handler.
And that’s it! It was honestly a lot less work than I anticipated. I thought I’d end up having to extend a bunch of Melee’s classes to get this to work, but thanks to Game Creator’s easy to use action and event systems it really wasn’t too much of a challenge.
Now to figure out how to use this with a bow and arrow…