phantomfox

Hi,
we are building a multi skeleton player controller in our game.
Until last month i was using a heavily modified version of the spine multi script, from the example files.
Since we are using a specific framework for the game (adventure creator), we had to update our approach for sequencing reasons.
I found a script from a different coder and adapted it, which links spine/unity runtime better to the framework.
In this script, the player controller consists only of one unity object and therefor one skeleton animation component.
If the direction-based skeleton is switched, he simple reloads another data asset into the skeleton animation component.

Is this a viable approach or will it lead to problems? (i am asking because in the example there are multiple objects, each with its own skeleton animation component).
if this is a viable option, could anybody tell me the right initalization sequence for this approach (in which order should i call which functions for flipping(x/y), skin setup, order in layer etc.)

thanks in advance
kind regards,
Max
phantomfox
  • 記事: 11

Harald

In general it is a viable option to switch the SkeletonDataAsset at runtime.
Be aware however, that the first time you switch to a previously unused SkeletonDataAsset, all the necessary data needs to be loaded. So during this loading frame performance will drop. Therefore you should consider pre-loading the required SkeletonDataAssets once during scene loading, if possible.
phantomfox さんが書きました: could anybody tell me the right initalization sequence for this approach
You can use the following order, it is especially important when switching to a different Skeleton that has different skin and animation names than the current one:
skeletonAnimation.skeletonDataAsset = newSkeleton;
skeletonAnimation.initialSkinName = newSkinName;
skeletonAnimation.AnimationName = "";
skeletonAnimation.Initialize(true);
skeletonAnimation.AnimationState.SetAnimation(0, startinAnimationName, true);
// you can add additional calls like flipping here
skeletonAnimation.Update(0);
アバター
Harald

Harri
  • 記事: 1500

phantomfox

Thank you very much for your quick answer, will try this init sequence and report the results

---

So, we have implemented the changes and tested it in dept. Besides minor quirks on my end everything besides one thing seem to be working.

This one thing is, like mentioned in previous posts, the reset to the setup pose. This happens often, but i could not find a pattern or obvious logic behind it.

For clarification: we are using a framework for unity (adventure creator) which we modified for spine. If the character is assigned a new direction he first switches the skeleton data asset in the skeletonAnimation component and is assigned the animations shortly after.
Ill attach a video and the two most important sricpts to the post. I implemented all your lines, tested the update(0) and lateupdate() functions on different spots, but could not get rid of the setup posing. We are using unity 2019.3 with the newest spine unity package(17.02.2020). -> we had the problem in 2018 and 2019.2 as well

Video:
https://imgur.com/iI4v1Aq

Maybe i did forget some init lines, or there is something going on in the framework, i am not aware of or something is wrong with the skeleton data itself. if there is any script i could test the skeletons against, that would be great. the multi spine script in the example files was tested by me in depth. same weird setup posing as well.
Please let me know if i can send you anything else that could help in catching that error.

thanks in advance
kind regards,
Max
添付ファイルを見るにはパーミッションが必要です
phantomfox
  • 記事: 11

Harald

Sorry to hear that there are still some problems remaining. I had a look at your code, unfortunately I do not see the respective code that calls this method:
public void SetCurrentDirection(string newDirection)
Is it called from Update, LateUpdate or anything else? This will be important to know in terms of which update calls come after this method (where in Unity's update order we are currently in).

I assume you already tried using both lines below enabled, as they were commented out but included in your code:
skeletonAnimation.Update(0);
skeletonAnimation.LateUpdate();
If you already tried that, I'm afraid we will need a minimal reproduction Unity project to analyze the problem any further. You can send it as zip package to contact@esotericsoftware.com, briefly referencing this thread so everyone knows who it belongs to.
アバター
Harald

Harri
  • 記事: 1500

phantomfox

My apologies, i simply uploaded the wrong file, the function call is in the AnimEngine_Spine.cs
i attached two other scripts that are depending/dependend on each other here.
I can send the stripped project tonight, but we use the framework adventure creator as a paid unity asset, so i am not sure if you are able to open the project.

Thanks again for the quick response and the in depth help.
Kind regards
Max
添付ファイルを見るにはパーミッションが必要です
phantomfox
  • 記事: 11

Harald

Thanks for sending the other files, I can now see at least more of the important code parts.

Without being able to run and debug the game it will be a bit of guesswork, but maybe we are lucky:
I just noticed that your call order is:
skeletonAnimation.Initialize(true); in DirectionMapper.cs:116
and then it returns to either PlayStandardAnim in AnimEngine_Spine.cs:1241, but not necessarily playing an animation there:
if (!string.IsNullOrEmpty (clip))
and I see no calls to either Update(0) and LateUpdate() thereafter?
It will be important to ensure that both 1) the animation is set in the same frame and 2) Update(0) is called, and eventually 3) LateUpdate() is called as well, everything in the same frame, before it renders the skeleton after LateUpdate. It would be necessary to know whether all the necessary calls are performed or if perhaps an if-condition evaluates to false and skips a necessary call.
phantomfox さんが書きました:I can send the stripped project tonight, but we use the framework adventure creator as a paid unity asset, so i am not sure if you are able to open the project.
If it is not including all necessary parts to run and debug it, it will not help unfortunately. I'm afraid you will then need to strip the project down to the bare minimum of the Spine runtime API calls that still lead to the problem. Unfortunately this might be just as hard as finding the problem itself.
アバター
Harald

Harri
  • 記事: 1500

phantomfox

Thanks a lot for the inspection, i implemented a Funtion that calls Update(0) and LateUpdate() regardless of the empty clip.
I testet the code in dept,but to my supprise the T-Posing was suddenly just gone. It reappeard after reloading Unity once, and was gone after a second reload again. Since then, there was no T-Posing any more. I know how crazy this may sound, and i can't believe it myself, but my college watched the whole thing and can confirm this. So afterall, it may have not been a fault in the code, but just some unity magic, which is way out of my understanding.
If the issue reappears again, we will defenitly send you the project, i will even send you me unity account credentals, so you have all the packages you'll need.
Sry to bother you with this really weird issue and thank you for all your help.
Sincerely
Max
phantomfox
  • 記事: 11

Harald

Thanks for getting back to us. Hopefully this was just a problem of some cached incorrect state.
アバター
Harald

Harri
  • 記事: 1500


Return to Unity