Melee combat
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.
This took a lot of tinkering, and the final solution has two invisible objects that are in the right rotation so that the script can reference them, because Quaternion is still a bit beyond me. This is what the swing looks like:
Here I've tried to show the two normally invisible objects which I reference for the swords start and end rotation.
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.
Big Sword
Status | In development |
Author | jofbob |
More posts
- Finished Game ProjectMay 30, 2021
- UI & sound stuffMay 30, 2021
- The player & the swordMay 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.