itch.io is community of indie game creators and players

Devlogs

Melee combat

Big Sword
A browser game made in HTML5

Developing the combat and figuring out how to swing a sword with physics was definitely the most time-consuming part of Big Sword. 

It took me a while to land on what I thought was a good solution (note the past tense and regret here).

I found a bit of code on stack overflow that I can no longer find the source for unfortunately, but it used Lerp to constantly bring an object back to the same location. So I adapted this so that I could update the position and rotation of the sword and then have it return back to normal always. 

It's perfect! looks really good and works well with the sword growth. Initially there were problems where if I moved around in the middle of a swing the sword would go all over the place, but I found I wasn't using the local position of the sword as a reference and that instantly fixed the solution.

The next part is to make it actually collide with enemies.

I wasn't able to figure that out at the time of posting this, as I need to have a changing collider that can also raycast all enemies hit but only when pressed by a certain button. My current solution achieves two of these things, but unfortunately does not change size which takes away a lot of the fantasy of the game.

Leave a comment