Skeleton Blending

Hey guys! I have a basic concept of how I’m supposed to blend two skeletons, but I can’t seem to find the right way to put it into engine syntax!

Here’s the code I have right now, but obviously, it’s not working as intended. Because I don’t know how I am supposed to do it.

var RootMotion = pc.createScript('RootMotion');

RootMotion.attributes.add('animationName', {type: 'string', title: 'Animation', default: 'Reload'});

RootMotion.prototype.upperSkeleton = null;

// initialize code called once per entity
RootMotion.prototype.initialize = function() {
    this.upperGraph = this.entity.model.model.graph.findByName("Spine");
    this.upperSkeleton = new pc.Skeleton(this.upperGraph);
    
    this.upperAnimation = this.entity.animation.getAnimation("Reload");
    
    ///////////
    
    this.oldAnim = this.entity.animation.skeleton.animation;
    this.upperSkeleton = this.entity.animation.skeleton;
    this.upperSkeleton.animation = this.upperAnimation.resource;
    
    this.upperSkeleton.addTime(0.0);
    this.upperSkeleton.updateGraph();
    this.upperSkeleton.animation = oldAnim;
};

// update code called every frame
RootMotion.prototype.update = function(dt) {
    // upperSkeleton.addTime(dt);
    // upperSkeleton.updateGraph();
};

Can anybody help out with this?

I may have found something that could help but it’s still not exactly what I’m looking for and it appears to be outdated and built to be standalone: https://github.com/chinedufn/skeletal-animation-system

Blending two skeletons is a question i have too. Is the blend supposed to output the two skeletons into one ? Then how do you use the result?

I’ve made a script for it. Once I clean it up, I will send it to you. Remind me in case I forget.

2 Likes

Would you be willing to share your script or send it to me? I’m currently struggling with skeleton blending and kind of stuck because of lack of documentation/ examples.

Thank you so much. Got it to work in my project. I’m playing a punch animation over an underlying idle animation. This works great, but the punch animation is not blending from the idle animation. The hand position just jumps to the initial position of the punch animation, plays through and then jumps back. Any idea how I could achieve blending between the layered animations?

2 Likes