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 ...

Get Procedural Content Generation for Unity Game Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.