Thank you for your reply. Unfortunately, none of the suggestions appear to work.
By way of clarification. The function that deals with the animation is called from Update but is separate to it.
I implemented the suggested code and this did not make a difference. I also changed the execution order in Unity, which also did not change anything.
What seems to happen is that the bones gradually change position as the sprite goes from walking sideways to walking forward. However, it does not happen in reverse i.e. when the sprite changes from walking forward to walking sideways. On the other hand, it does happen if the change is from walking forward to side 'Idle'.
This is what the code that deals with the change from side to forward:
void PlayerMovementVertical()
{
if (moveVelocity.y < 0)
{
if (skeletonAnimation.skeleton.data.FindSkin("Front") != null)
{
skeletonAnimation.skeleton.SetSkin("Front");
skeletonAnimation.skeleton.SetBonesToSetupPose();
}
if (skeletonAnimation.state.GetCurrent(0).Animation.name!=("Walk_front"))
{
skeletonAnimation.state.Apply(skeletonAnimation.skeleton);
skeletonAnimation.state.SetAnimation(0, "Walk_front", true).TimeScale = 0.5f;
skeletonAnimation.skeleton.UpdateWorldTransform();
}
}
if (moveVelocity.y==0 && skeletonAnimation.skeleton.Skin.Name==("Front"))
{
if (skeletonAnimation.state.GetCurrent(0).Animation.name != ("Idle_front"))
{
skeletonAnimation.state.SetAnimation(0, "Idle_front", true).TimeScale=0.6f;
}
}
}
I cannot figure it out. Any further help will be much appreciated.
Thanks
Managed to get it to work. In addition, to the suggested code I set the Default Mix Duration to 0, this had not previously worked, but worked with the suggested code.
I need to look into this matter further so I fully understand the issue and how it has been resolved.
Grateful for your help.
Further note. It only works if I set the Default Mix Duration to 0. If I set the mix duration for the specific animations i.e. walk to Walk_front to 0, this will not work.