StormWeaver

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;
}
StormWeaver
  • Postovi: 3

clandestine

What happens when you replace the SE animation with a test animation? Does it still behave the same way?
Avatar
clandestine
  • Postovi: 48

StormWeaver

clandestine je napisao/la:What happens when you replace the SE animation with a test animation? Does it still behave the same way?
Oddly enough if does not. I replaced it with one of the other directions and it seems to work fine. So, from the looks of it when going SE it cant change to SW but it does not happen when any other direction is put into ether category. Honestly I'm at a loss for what is wrong.
StormWeaver
  • Postovi: 3

ciaps

Might this be related with your SE animations not being keyed at the first frame?
Avatar
ciaps
  • Postovi: 21

StormWeaver

ciaps je napisao/la:Might this be related with your SE animations not being keyed at the first frame?
Fixed it, the issue was that the X-axis flip i used to create the two animations weren't always keyed at the start and end and since the animations were the same buy flipped, it always looked like it was only showing one of them. Thanks for the tip, everything seems to be working now.

Thanks!
StormWeaver
  • Postovi: 3


Natrag na Unity