Hi all,
We are developing our second RPG game, using Unity and Spine again.
The mechanics of the game are quite complicated. Therefore the speed of each animation may change each frame. So it is best if we keep the game logic separate from the rendering and apply a certain animation time each frame.
I know that this is a common question and I have read many other answers. All of them seem out of date. Actually it was these forum posts that enabled us to come up with an implementation for our previous title last year. Our (hacky) solution has been this way:
Spine.Unity.SkeletonAnimation skeletonAnim;
Spine.Skeleton skeleton;
Spine.Animation anim;
void Set(float time){
skeleton.SetToSetupPose();
anim.Apply(skeleton, 0, time, false, null); // maybe call lastTime as time???
skeletonAnim.UpdateCustom();
}
//inside SkeletonAnimation.cs
public void UpdateCustom() {
if(!valid) return;
skeleton.Update(0);
state.Update(0);
state.Apply(skeleton);
if(_UpdateLocal != null)
_UpdateLocal(this);
skeleton.UpdateWorldTransform();
if(_UpdateWorld != null) {
_UpdateWorld(this);
skeleton.UpdateWorldTransform();
}
if(_UpdateComplete != null) {
_UpdateComplete(this);
}
}
We came up with this solution through trial and error and lots of pain along the way. Before this implementation things usually seemed to work fine, but there have always been occasional visual artifacts. This hacky implementation seemed to work without any problems, besides our un-profiled performance metrics.
Now we have updated to Unity5.6.2 and Spine 3.6 and we need a similar functionality.
We see that Spine.Animation.Apply function got more parameters now. This is not a problem, although we do not need any of the new parameters and it would be nice to have a simpler API. Our problem is that this approach does not seem to work any more. It was a hacky solution anyway, and we would like to implement things cleaner this time.
We would really appreciate if we can get a concrete implementation for our needs. What we need is to set these manually every frame:
- The animation being played.
- The time that the animation should render this frame.
- Skins, attachments.
I know this is not the "Unity way" of doing things, but that is just how our team rolls ^^
Thank you very much,
Tarik