FSGD Final Project Week 6: Animator Controller and Attack

Yo, so last week went pretty well. Definitely our best build by a decent margin. Playing through the game with my teammates is actually pretty fun, and I’m excited to see how all of these pieces are coming together. I’m definitely excited to keep on improving the game because it seems like we have something special going. Here are some of the improvements I made to the game and engine last week.

The majority of my time was spent working on the animator controller. During week 5, I spent a good amount of time getting the classes made with the basic functions, and this week I spent adding more functionality and making sure it worked through the network.

So because I had most of the basic functions made, I just had to actually set up the animator controller for the mage. This means I had to make the states (idle, run, and stumble), triggers (idle and run), transitions (idle to run, idle to stumble, run to idle, and stumble to idle), and add the conditions for the transitions to happen. This takes up a couple dozen lines of code. If you know Unity, this is all represented by GUI, but I had to code dynamically allocating every object, initializing every object, and setting the correct references.

With this done, I could debug and see what I had preventing the animator from working correctly. Without networking, I had a bug where the blending of an animation would happen twice for some reason and a bug where the server’s player’s animation would happen twice as fast as the client’s. I honestly forget how I fixed the blending error, but I remember for the speed error it was because I was calling the update on all of the server’s components then later I specifically called update on the animator, which is a component,. Simple fix: just don’t update it the second time with another if condition.

Now, the hard part would be getting the animator controller working through the network even though it worked locally. The first way I did it made the animation not have any blending on the client. That’s was because I only had functionality for the client to just set the current animation. Instead, I wanted the transition to be notified that it should happen because the transition does blending. I also needed the client to know what transition it actually needed to be done.

So I sent a transitionIndex. With this transitionIndex, I could use the curStateIndex, which I store in the animator controller, and get the transition and use that to transition to the next state. I had one error that took me about 2 hours to find, but I eventually found it. And now the controller works. It was as simple as setting a timer in the transition object to 0.0f. This not happening caused the stumble animation to never happen (even though it did happen, just really fast).

Once I had the animations working, specifically the stumble, I could get the attack working, so the player would drop the ball if attacked. Nothing sophisticated, just when a player collided with another player, the player stores a reference to that player. If the player presses the attack button and it has a reference to a player and that player has a ball, the other player will drop the ball. I had a bug where it wouldn’t drop correctly due to it recolliding with the crosse right away, but I eventually fixed that with the proper physics and translation.

The only thing that sucks is that it still seems like I have a bug that pops up after a while in regards to a transition index being out of range in the vector on the client side. That’s something I’ll have to look into this week. Before that though, I really want to get networked, 3D sounds.