playcanvas / playcanvas/engine

Masks in the Animation State Graph are not applied if the skeletal hierarchy is not a child of the entity that has the Anim component

Open
#5,938 0 comments 0 reactions 1 assignee View on GitHub

@kpal81xd is already working on this.

Since Jan 10, 2024.

area: animation
Dominant language
JavaScript
Stars
16.8k
Forks
2k
Avg merge
4h 32m
Merged PRs (30d)
222

Description

Description

When applying a mask as part of an Animation State Graph Layer the mask is not properly applied if the skeletal hierarchy is not a direct child of the entity that the Anim component is on.

Demonstration project: https://playcanvas.com/project/1172859/overview/animation-masks-template-bug

Both of the characters are set up to loop a run cycle in the base layer, with a sword swinging animation masked onto the upper body. Only the one where the bone hierarchy is a child of the entity holding the Anim component works.

As this is how the entity hierarchy is defined automatically when you import a model, it requires us to remember to make a change after importing each new model.

Steps to Reproduce
  1. Create a simple animation graph with two layers
  2. Set up the entity as it would be on a normal import of the model:
Screenshot 2024-01-10 at 10 33 59
  1. Set the second layer as masked onto the base.
  2. Observe that the mask is not applied.
  3. Duplicate the entity and edit it so that the skeletal hierarchy is a child of the entity with the Anim component
Screenshot 2024-01-10 at 10 35 26
  1. Observe that the mask is correctly applied.
Screenshot 2024-01-10 at 10 36 07

This restriction on entity hierarchy appears to be being enforced in components/anim/system.js in the cloneComponent function: The copying logic only occurs if you're either not specifying the rootbone, or if the rootbone is also the anim component entity.

cloneComponent(entity, clone) {
        let masks;
        // If the component animaites from the components entity, any layer mask hierarchy should be updated from the old entity to the cloned entity.
        if (!entity.anim.rootBone || entity.anim.rootBone === entity) {

(which appears to be part of a fix for an earlier issue with masks)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.