Hello!
I am trying to animate a crocodile, swimming, then turning by 180 degrees and swimming on again.
I made this little video which shows the problem that I am having. At 0:50 you can see the animation in action.
What I did: I made seperate animations:
two for swimming :
- the y axis stays at 0, the body is oriented downwards ("normal" swimming, swimming in one direction)
- the y axis stays at 0, the body is oriented upwards ("reverse" swimming, swimming in the other direction)
two for turning:
- turning from downwards facing to upwards facing
- turning from upwards facing to downwards facing
The turning animations are made so that they start with their origin at 0,0 (the head) and also end with their origin at 0,0, only with the body on the other side of the axis respectively ( i hope that makes sense but you can probably see it from the video)
Here is the handling function which is supposed to switch from the turning to the swimming animation:
void MyEvent(Spine.AnimationState state, int trackIndex, Spine.Event e)
{
if (e.Data.Name == "TurnComplete" && CrocAnim.AnimationName == "turn")
{
CrocAnim.state.SetAnimation(0, "swim_reverse", true);
}
}
Where "TurnComplete" is an event thats triggered at the last frame of a turn.
Why is it behaving so badly? What can I do to fix this?
So far, Skusku
20 Oct 2015, 16:34
[/b]
Ok so I got it working.
The problem was a) flipping and b) rotating during the animation.
In the reverse_swimming animation I had rotated the root bone by 180° degrees to achieve flipping.
However in the turning animation I rotated the first head bone during the animation and left the root bone untouched ( I basically rotated the whole object around the root bone)
So basically after the turning animation the root bone's rotation would still be 0, but the "reverse_swim" animation's root bone's rotation would be 180°, making the whole thing turn around it's own axis.