torsdag 2 mars 2017

5SD064 Animator Controller.

Animator Controller.


Hi i'm Kevin from team Fenrir. I'm one of the programmers in my group and also the lead sound person. This week I have been working with switching between animations on the player. I have been doing this because me and my team wanted to have animation for the player walking and since the artist of our group is done making the animation sprites I am now implementing them. Before this I had only been putting in animations for objects that only have one animation. So I have been learning to use the animator controller in Unity.

So the player has animations for walking up, down, right and left. when I started doing this I thought that all you had to do was write in the script to play a certain animation at specific times but this could not make the player switch between animations. The way you actually have to do this is assigning triggers, floats, ints or bools for transitions between animations. I decided to assign floats for the transitions which are like if statements outside the script. In the script I assigned the float for the transition to my "Input.getAxis" floats by using the "SetFloat" command. So now when i'm using these transitions the animations do switch but not very properly for some reason the player switch to the ideal sprite from time to time at moments where it shouldn't, but i think this has to do with the pattern of my transitions. It's also possible that the problem would be that the "Input.getAxis" float is the wrong variable to assign the transition to. Maybe I have to assign it to "Rigidbody.velocity" or something.


Now in the last couple weeks of our projects our game is really coming together but I still have to make these transitions work and some minor fixes from our feedback on the play testing session we had on Monday. Next week i'm going to have to make it so that the player can tackle the enemies and a better visual feedback for when you lose health, but before that i have to wait for some sprites to be done by the artist in our group.

1 kommentar:

  1. Hey Kevin, it's good to see that you have a nice set of animations to work with and that you've taken up the Animator component to combine and work with them. You seem to have setup the animations right in the Unity Editor.

    As far as what could be going wrong for you to be getting the wrong animation playing at the wrong time, I would say that it's probably because of how you are calling the triggers. I think that you should definitely be using the player velocity instead of the Input methods, since if you are colliding with something and you continue to push towards it, the input will always say that you are trying to move, but the velocity itself will determine if you're actually moving or not. Best way to get a lerped float between 0 and 1 is to take the direction you are looking at (Either X or Y) and divide it by your maximum speed.

    You should also tie the playback animation to your velocity to create a nice smooth effect, that is if your character doesn't reach maximum velocity immediately on key press.

    SvaraRadera