This week my focus was to make the animation for reloading the bolt of the rifle work alongside the button pressing sequence. This was difficult to do and I had a lot of problems trying to do this but now the rifle’s reload sequence works.
The animation for reloading
As I said in this blog post back in January, I had created the full animation for the rifle, however I was having problems with the bolt not behaving as I intended (rotating the wrong way). Luckily I found an easy solution for this which was to change the interpolation for the rotation of the bolt to quaternion as shown below:
Once the bolt rotation was working as intended I finished creating the whole reload sequence as one long animation. However, I soon found out whilst coding that using one long animation would be very difficult compared to breaking up the animation into four short clips. That way I can assign the short clips to the button presses in the sequence rather than having to try stopping and starting one long animation.
Once the short clips were created I could then continue on to mirroring the clips to the key presses in code.
The code for reloading
Since I already wrote the code for reloading (as I put on my previous blog post here) all I needed to do was make sure the animation clips played alongside the key presses. What I needed to do was create 4 triggers which will activate between each button press playing through each animation clip.
The last concern was whether I should make a separate animation for players reloading whilst aiming down the sights. Although I feel this would be nice to have I feel it is not essential, so for now I will lock reloading so players can only reload whilst not aiming.
Here is a video demonstration of the reload sequence. I have added a trail to the bullet for debugging purposes to see the bullet as I shoot it, this will be removed when I get players to test the gun.
The basics of the rifle is complete. Now I need to start testing the rifle for any bugs and making the bullet collide with objects. I then want to create some mock targets to practice shooting to see how accurate the bullets are.