Blog #1 – Prototyping Combat
Hello everyone and welcome to the first Amber Roots development blog! I’m hoping to post these up here on the website on a weekly to bi-weekly basis. The purpose of these is to fill in the gaps a bit between videos.
Videos take a decent amount of time to make, and so I thought maybe I can split up the updates using these written blogs. Right now what I’m thinking is videos will present a more polished, update style look at Amber Roots, while these written blogs will be more technical and show how I got there.
Of course this is subject to change based on feedback so let me know what you think!
The Basic Combat Scene
One major system that has been missing from Amber Roots since the transition to 3D is combat. I was planning on just importing the classes and systems over from the 2D project and just tweaking the things that needed tweaking, but when I was working on getting the Amberling house system going I had a little inspiration.
Before I could try any type of combat system out though I had to build a combat scene that could load in Amberlings and initiate combat mode. I made a very simple scene in no time and made a class named TeamSpot which basically loads in Amberlings after checking what Amberlings the player has in their team, and what enemy Amberlings were interacted with to initiate combat. So once combat starts, those Amberlings are read in and the unused TeamSpots are turned off.
This part was simple enough since I already had a scene loading system in place. Now I wanted to recreate the turn based system I had in the 2D game, but with a bit of a twist. This took a decent amount more work. What I had in mind was a system that would let the player control the Amberlings in their team during their turns. The Amberlings would control just like they do outside of combat, and so the player could move around, jump, use abilities like breaking down rock walls, etc.
So rather than picking your target from a list, or clicking on them from an overheard perspective like many other turn based games, the player would have to pick a combat action (e.g. attack), move to the target so that the action would be in range, and then perform said action. In order to make combat feel a bit more fluid and maybe a little hectic I also decided to add a turn timer. Meaning, the player would have a limited amount of time to pick the action, move, and perform the action. I even thought that the amount of time each turn takes could be dictated by how fast the Amberling is, making speedier Amberlings be able to do more in a single turn. I thought that this system sounded like a lot of fun and really wanted to try it out. Almost like a tactical grid based system, but with freeform movement, and WASD controls since it uses a 3rd/1st person camera. I know that timed turns aren’t always everyone’s cup of tea, so I fully plan to make the turn timer an optional system.
So I got this system working and I’ve been pretty happy with the result. I have a list of Amberlings participating in combat that is sorted based on their speed, so the faster Amberlings go first. The player can freely control their Amberling during their turn, and the timer counts down, and once it reaches 0, the next turn is set up.
A few notable things are still missing though. I haven’t imported the Amberling stats system yet so the speed I’m using to determine turn order is a very basic variable. As such I did not implement the variable turn time yet, I’ll revisit that once I import the Amberling stat system. Related to that, all the Amberlings currently have an arbitrary amount of HP for the same reason. Another major missing feature right now is a proper action system. I had begun working on the action system (different types of attacks, status effects, etc.) in the 2D game but it was pretty bare bones. So right now, you can’t pick what action your Amberling will perform, there’s only a basic attack that does a flat amount of damage. I need to make a new system with a variety of attacks, resistances, extra effects, etc. but this will likely come in a future update.
Getting enemy movement was super easy with the A* pathfinding system. I colored their sprites purple until I can make some nicer corruption effects, and I already have classes dedicated to moving Amberlings around so it was only a matter of allowing/disallowing movement based on whether or not it was currently that enemy Amberling’s turn. So I made an EnemyAIMovement class to handle all this, and right now when the enemy’s turn begins, this class just picks a random target from the player’s team, picks the basic attack action, and moves towards that target until it’s within range of that action.
With the very bare bones HP and damage system in place, I was able to implement KOs when an Amberling reaches 0 HP. When this happens, the TeamSpot that the Amberling belonged to deactivates that Amberling, removing it from combat. The TeamSpots are really flexible and in the future I hope to implement things like revives for the player Amberlings and maybe even new enemies joining the battle under certain conditions.
So after every combat turn, the CombatManager checks the state of all active Amberlings in combat. If it determines that there are no active Amberlings in either side (enemy or player) combat ends. That’s it for now, no XP, or real consequences to winning or losing. I need to get the Amberling stats system working before I can really do anything like hand out XP.
Player Controller
One of the other things I had to do this week was dig into my PlayerController class. It’s one of the first classes I wrote when I transitioned to 3D, and as such it’s guilty of being way too long and handling way too many things. It was handling player movement, player animation, gravity, camera switching, and raycasting for detecting interactables. So yeah, that was getting a bit messy. A few of the things I ended up working on this week had me updating my raycasting and camera code so I though it was a great time to split those off from PlayerController into their own classes.
The CameraManager class now handles all the camera switching, and anything having to do with cameras really. I’m experimenting a bit with it so it’s a little messy right now. I’ve never worked with Cinemachine before, other than simple 1st and 3rd person cameras so I’m trying to figure out how to have cameras do interesting things. I’m also testing out Unity’s timeline system along with it to see if I can get some cool shots during combat. It definitely seems like I’m heading in the right direction though there’s still a lot I need to figure out.
I made a timeline for two combat cameras that transitions from an overhead view to looking at the Amberling whose turn it is. So this clip plays in-between turns currently. Pretty basic stuff but I’m excited to add a bit more of a dynamic system. Cinemachine seems super deep and flexible so it’s really just a matter of figuring out how to do it on my end.
I also moved all the raycasting functions to a new class, so while still not perfect, the PlayerController class is looking a lot cleaner. I hope as I continue forward I can simplify it even more.
Final Thoughts
That about wraps it up for this first blog! I’m pretty happy with how the combat system is coming together. It feels a little different than the usual turn based systems, and I think taking control of your Amberlings during combat in the same way you do it out of combat really ties together the exploration and combat system.
I hope everyone enjoyed reading this and found it interesting. I’d love to get some feedback on it, and like I mentioned, I’d like to try to do this on a weekly to bi-weekly basis to keep everyone more up to date on what I’ve been working on.
That’s it for now, and thanks for reading 😀