I have setup a character in unity that has four directional animations. South-West, North-West, North-East, and South-East facing. Each of these works perfectly and translates smoothly between each other option, however for some reason I cannot transition between South-East and South-West, though i can translate in reverse from SW-to-SE.
Below is the code I use. It determines the direction that the character is heading and assigns an animation based on the movement. One thing I have noticed is even though the animation for South-West does not play, the inspector does accurately show that the South-West animation is active when looking at the Skeleton Animation (Script).
public GameObject spinePlayer;
public SkeletonAnimation skeletonAnimation;
float x;
float y;
string currentAnimation = "";
void Update () {
x = Input.GetAxis("Horizontal");
y = Input.GetAxis("Vertical");
if(y > 0 && x < 0){
SetAnimation("Walk-NW", true);
}
else if(y > 0 && x > 0){
SetAnimation("Walk-NE", true);
}
else if(y < 0 && x < 0){
SetAnimation("Walk-SW", true);
}
else if(y < 0 && x > 0){
SetAnimation("Walk-SE", true);
}
}
void SetAnimation (string name, bool loop){
if (name == currentAnimation)
return;
skeletonAnimation.state.SetAnimation(0, name, loop);
currentAnimation = name;
}