- Edited
Possible To Eliminate Vertical Movement?
Currently we are driving all jump movement in engine. Our animator is currently animating jumps with vertical movement (makes it easier for her) showing us, and then eliminating the vertical movement after in order for us to throw in game engine.
This is a sort of tedious process and were wondering if Spine has some feature we don't know about to lock the vertical / horizontal movement on export. Is this just par for the course or are we doing something wrong here?
Thanks in advance!
You could export with the vertical movement, then nuke it at runtime, after loading the skeleton data. To do that, get the animation with SkeletonData findAnimation
and iterate through the Animation timelines
to find the TranslateTimeline for the root bone. That will be the one where TranslateTimeline boneIndex
is 0. Finally, remove that timeline from Animation timelines
.
If you're still a Unity user, removing it at load time would look like this:
SkeletonDataAsset skeletonDataAsset;
SkeletonData skeletonData = skeletonDataAsset.GetSkeletonData(true);
// For all animations
foreach (var animation in skeletonData.Animations) {
int timelineIndex = -1;
var timelines = animation.Timelines;
// Look for the TranslateTimeline for the root bone.
for (int i = 0, n = timelines.Count; i < n; i++) {
var timeline = timelines.Items[i];
var translateTimeline = timeline as TranslateTimeline;
if (translateTimeline != null && translateTimeline.BoneIndex == 0) {
timelineIndex = i;
break;
}
}
// Remove the TranslateTimeline if it's found.
if (timelineIndex != -1)
animation.Timelines.RemoveAt(timelineIndex);
}
In Spine-Unity for Spine 3.7, the new SkeletonDataModifierAsset system allows you to write this as an asset, and then just add it to your SkeletonDataAsset inspectors for the skeletons that you want it to be applied to.
What you need is a transform constrain with x,y component separated which is not available in current version.
I also faced the same problem when animating character jump, I ended up using two bones to control the X,Y of the jump which make sense if you want realistic gravity on Y while using different easing function on X. After the animation is done, just disable the X movement by using transform constraint to lock the position of X bone.
Awesome thanks so much for all these replies. I'll pass along the info to our animator and see if we can get a better workflow in place.