The player & the sword
I always knew the hardest part of Big Sword would be figuring out how to do the sword combat and fulfilling the gimmick of making it grow, so lets look at my process of figuring that out. To start with the player who is really just a harness for the sword, I made a test sprite which I showed off in the enemies log, this guy is my stand in until I figure out a better sprite for the player.
I grabbed a movement script from one of the practicals (Eight way movement), gave him an appropriate speed and away he went (forgot to record a gif of the old sprite, but know that he moved well). That's the easy part, lets get onto the hard part, the sword. I went through a lot of art trying to design the sword myself, like these:
Don't mind the size, I was still trying to figure out pixel art in GIMP.
Right from the start I knew the implementation of the sword that I had in mind comprised of three different sprites, a bottom component with the handle, a middle component, and a top component. As long as shading stayed consistent and the art simple I could duplicate the middle component as many times as a I wanted and sandwich them in between the top and the bottom. Eventually I moved on from trying to do this with pixel art and created these monstrosities:
The in game implementation of this has the bottom component stay static, and an array of middle component prefabs either enabled or disabled depending on how long the sword is, and finally the top component sitting on top of all the enabled middle ones. Initial testing looked sort of like this:
Pretty buggy, especially the top component not behaving, as I have to dynamically figure out where the end of the sword is and place the top component there. I spent a good few weeks figuring the kinks in this sword and yes I did eventually update the sprites to a much nicer sword I found on open game art: https://opengameart.org/content/game-weapon-long-and-short-sword
I did have to edit the sword quite a bit to get it to work for my game but thankfully I've grown comfortable and confident with GIMP enough to do so. After a lot of deliberation and testing I decided to try something else for the sword implementation, as the code was getting complicated and it was a pain to fix. I tried creating an individual sprite for each length of the sword, rather than dynamically updating it in game I could just have a bunch of different sprites in a sprite sheet and then change the sprite as I go. In GIMP this looked rather cool:
As I stored each sword on a different layer.
I thought this would take a lot of time but I managed to create an easy workflow for myself and it was rather painless. In Unity I wrote a simple script to update the sprite based on an integer and a sprite array with each one in it. It came out rather nicely as a result, and gives me a lot of wiggle room for sword length:
Note that the size isn't permanent and may become smaller to match the map size.
Okay so I've figured out sword length and how to change it, but how do I handle actually swinging the sword and combat? Normally you would do this with animations but I'm not going to create a different animation for each state of the sword. Instead I opted to do it with Unity physics and Lerp.
I'll cover that in a melee combat post.
Big Sword
Status | In development |
Author | jofbob |
More posts
- Finished Game ProjectMay 30, 2021
- Melee combatMay 30, 2021
- UI & sound stuffMay 30, 2021
- Enemies & SpawningMay 30, 2021
- The basic levelMay 30, 2021
- Game ConceptApr 15, 2021
Leave a comment
Log in with itch.io to leave a comment.