- Düzenlendi
how to overwrite animation's attachment programmatically
Hello,
My spine character has gestures.
it has looks parts that consist of brows, eyes, nose, mouth.
and gesture animation has looks skins for facial customization.
for understanding, refer this https://youtu.be/nqmJFNHrqxY?t=3m40s
it also can change looks only without gesture animation.
problem is when they are executed simultaneously, gesture animation keeps own looks parts skin
ignoring independent look changes.
animations are made by spine, run by state.setAnimation.
and changing looks only affected by code, slot.setAttachment.
I want that slot.setAttachment overwrites animation's attachment.
is that possible?
Thanks.
What Spine runtime integration are you using? Unity?
@klaude, I will have to try the same (or at least similar) thing soon. I was hoping that if the animation contained no keyframes that set the attachment on the same slot, I'd be able to combine calls to setAttachment() with a playing animation.
Hmm. I'm inspired to stop watching Youtube videos and go code it up.
Experiment results: It works fine, at least for what I am doing. The animation plays without conflicts. I am also using calls to AnimationState.setAnimation() and Slot.setAttachment().
@badlogic
spine-ts i'm using it.
@[silindi]
Yes, you are right.
If the animation has no keyframes of a slot, that slot can be replaced by setAttachment() during play.
But in my case, animation has a slot, and i want to change the slot at runtime.
I think It's possible with creating new animation and combine by track in Spine or programmatically.
prefer the latter and idk how to do.
I don't know if this works, but maybe worth a quick try...
In your frame render code, first apply the active animation with delta, then call setAttachment and apply the skeleton. My thinking is that the second action should overwrite the changes made by the first. Some example code:
const state = ... /* your AnimationState variable used earlier to play animation. */
const skeleton = /* The skeleton affected by the animation. */
const slot = ... /* The slot of your skeleton that will have its attachment set. */
state.update(delta);
slot.setAttachment(attachment);
state.apply(skeleton);
skeleton.updateWorldTransform();
Nate or somebody more knowledgable could give you a better answer, I'm sure. But maybe it helps.
Yep, you can set the Slot attachment
before or after you apply your AnimationState each frame.
hmm.. It doesn't work during animation even set attachments every render loop.
I will inspect more my codes, setTimeout things may ruin.
Thanks.