What I need is what the speed of the player is, the animation should go faster and slower. Right now, I this little snip of code which Unity doesn’t seem to like it. It also seems that I am not able to access the animation in the ‘Animation Editor’. I also added an ‘Animation Component’ to the Player and from my animations folder, I dragged the animation onto it. If you could help me, it would be greatly appreciated. Thank you.
//Animation
var absVel = Mathf.Abs (rigidbody2D.velocity);
if (absVel < 0.1f) {
animation["WhaleSwimAnimation"].speed = 0.1f;
} else if (absVel < 0.5f && absVel > 0.1f) {
animation["WhaleSwimAnimation"].speed = 0.3f;
} else if (absVel < 1 && absVel > 0.51f) {
animation["WhaleSwimAnimation"].speed = 0.7f; }
else if (absVel < 2f && absVel > 1f) {
animation["WhaleSwimAnimation"].speed = 1f;
}