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
@kpal81xd is already working on this.
Since Jan 10, 2024.
- 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
- Create a simple animation graph with two layers
- Set up the entity as it would be on a normal import of the model:
- Set the second layer as masked onto the base.
- Observe that the mask is not applied.
- Duplicate the entity and edit it so that the skeletal hierarchy is a child of the entity with the Anim component
- Observe that the mask is correctly applied.
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.