Adding scripted weapon animation
The art we imported for our weapon modules is static, which means that we didn't add in any supplemental art to create animations. If we had added in these animations, our art assets would have increased dramatically, and we are trying to avoid this. So, instead, we are going to do what we have been doing and rely on programming.
We want the randomly constructed weapon to animate a swing when the player attacks. So, we are going to program the animation in such a way that it is the same for all the Weapons. This process is very much based on experimentation to get the right look and feel. One solution can be seen in Code Snip 6.8. The code is in the Weapon
class definition as the Update
function definition:
1 void Update () { 2 if (inPlayerInventory) { 3 transform.position = player.transform.position; 4 if (weaponUsed == true) { 5 float degreeY = 0, degreeZ = -90f, degreeZMax = 275f; 6 Vector3 returnVecter = Vector3.zero; 7 8 transform...