- Edited
animationStart Assistance
Good Evening!
When my player begins the walking animation, I want it to start halfway through the animation. animationStart seemed perfect for this. Though, even though I reviewed the documentation, I can't seem to get this right! :tear:
I was under the impression OnSpineAnimationStart is called anytime a new animation begins, but it doesn't seem to be executing.
public void OnSpineAnimationStart(TrackEntry trackEntry)
{
if( trackEntry.TrackIndex == 1) // walking set to 1
trackEntry.AnimationStart = .3f;
}
Any help would be great appreciated
Did you register the method for the start
event like the following?:
skeletonAnimation.AnimationState.Start += OnSpineAnimationStart;
If you are not sure where to put the above code, please see the code example in the following sections of the spine-unity documentation:
spine-unity Runtime Documentation: Processing AnimationState Events
Misaki wroteDid you register the method for the
start
event like the following?:skeletonAnimation.AnimationState.Start += OnSpineAnimationStart;
If you are not sure where to put the above code, please see the code example in the following sections of the spine-unity documentation:
spine-unity Runtime Documentation: Processing AnimationState Events
Oh, whoops, that's exactly what the issue was. I did not register the method in the start event. :bigeye:
Thank you, Misaki! :grinteeth:
Though, I do have another question. Is there anyway to make this happen only one time?
For example: My walk animation loops. So, the first time, I want it to star half-way through the animation, but after, I want it to start at the beginning or 0 for the next loop. :think:
Though, I do have another question. Is there anyway to make this happen only one time?
For example: My walk animation loops. So, the first time, I want it to star half-way through the animation, but after, I want it to start at the beginning or 0 for the next loop. :think:
You can play the walk animation with loop: false
at first and add the walk animation again with loop: true
like this:
var trackEntry = skeletonAnimation.AnimationState.SetAnimation(0, "walk", false);
trackEntry.AnimationStart = 0.3f;
skeletonAnimation.AnimationState.AddAnimation(0, "walk", true, 0);
Misaki wroteThough, I do have another question. Is there anyway to make this happen only one time?
For example: My walk animation loops. So, the first time, I want it to star half-way through the animation, but after, I want it to start at the beginning or 0 for the next loop. :think:You can play the walk animation with
loop: false
at first and add the walk animation again withloop: true
like this:var trackEntry = skeletonAnimation.AnimationState.SetAnimation(0, "walk", false); trackEntry.AnimationStart = 0.3f; skeletonAnimation.AnimationState.AddAnimation(0, "walk", true, 0);
This worked great. Thanks! 8)