I got a little excited when I got the combat actually playable and worked on it for 13 hours on Wednesday. So yeah, today I'm just gonna write this and take it easy. On Wednesday though, the combat started to look and feel pretty good already. I'll still have to mess around with the camera, figure out how to visualize the enemy's health and add a lot of things, but that's gonna be after getting the stealth mechanic working and seeing how it all plays out.
I had trouble keeping the player at a hittable range. The problem wasn't only that the enemy wouldn't hit but more that the enemy got "pushed" when trying to move back to the hittable range. It probably could've worked with some precise movement, but that means a lot of time for polishing. I thought a more interesting way to keep the player at a distance would be a kick.
This seemed like a great idea but still required some coding for the push. In the end I decided that this wouldn't be an obstacle for adding it because the pushing code would probably get used a lot in the future. Currently the actual push is just roughly timed and the strength over time is controlled with an animation curve and I don't think that that's going to be changing because it really might not even matter.
The kick ended up being a great and time efficient way of preventing the player from drilling the enemy's shins to dust.
I also got some great sounds in, thanks to Eponn on FreeSound.org. The WeaponInfo ScriptableObject has a list for swinging sounds and impact sounds (per weapon of course). Then when swinging I just get a random one different from the previous and play it with the help of an AudioSource pool.
I thought AudioSource pooling can be useful in any project, so if you wanna save a couple minutes on writing one, download this. AudioSourcePool (Isn't optimized or anything)
I decided to disable behaviour tree evaluating totally while the enemy is dead or disabled. After this I got almost all of the functionality out of the EnemyBehaviour and into the behaviour tree nodes.