Day 31: Dealing damage
- neelvinay17
- Aug 6, 2023
- 1 min read
My plan for the day:
I wanted to add in a dummy enemy that would simply serve as a mere temporary representation of how the game would look like when the player's sword collided with the enemy. What I accomplished:
I started off by adding a weapon damage collider to the sword on the player's left hand. I did this by adding a quick line of code that in simple terms, looked through the player inventory and slots script to find the weapon model currently in the player's left hand, make a connection with that. Once that was done, I repeated the same process for the right hand. Having done most of the coding relatively quickly, the important part was now finding the right key frames for as to when I should open and close the damage colliders. To do so, I opened up the animation window, and next to the scene view, carefully looked through the attack animation. At the point where the sword seemed to collide with the enemy, I opened the damage collider, and when the sword passed the enemy, I closed it. This ensured that the weapon would only deal damage during those key frames, and not whenever it was just hanging around. With the major component out of the way, I imported an enemy model in, added some take damage and death animations, and was done in the next fifteen minutes.
______________________________________________________________________________________________________

Image Source: https://unityassets4free.com/sword-animset-pro/




Comments