playcanvas / playcanvas/engine

Inconsistencies with Anim component.

Open
#6,390 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

Recently I was working with animations and met with various problems. Two of them I was able to isolate and reproduce consistenly.

  1. Adding layer via code seems to overwrite Base layer temporary if no animations are added to anim base layer.

https://playcanvas.com/project/1216249/overview/anim-layer-bug

var upperBodyLayer = this.entity.anim.addLayer(
        'UpperBody',
        this.blend,
        upperBodyMask,
        pc.ANIM_LAYER_ADDITIVE
    );

After adding new layer, logs shows that baseLayer name becomes added layer name. However if you assign any animation to base layer it becomes a mess.

-----------------------BEFORE ASSIGNING ANIMATION----------------------
this.entity.anim.baseLayer.name= : UpperBody
upperBodyLayer.name= : UpperBody
this.entity.anim.findAnimationLayer(`UpperBody`).name = : UpperBody
this.entity.anim.assignAnimation(“ClapAnim”, this.clapAnim.resource);

Animation layers are corrupted after assigning animation via code.

----------------------AFTER ASSIGNING ANIMATION----------------------
this.entity.anim.baseLayer.name= : Base
upperBodyLayer.name= : UpperBody
this.entity.anim.findAnimationLayer(`UpperBody`).name = : Base

That follows transitions not working and other weird behaviors.

  1. Anim component additive layer mode does not work correctly if anim component is not on entity with Render component.
    https://playcanvas.com/project/1215543/overview/breaking-the-rig 1
    If Anim component is on different entity than Render component, then animations in same Base layer works correctly, but if you add another layer and set blend type to additive weird scaling behavior happens. It scales down model in weird proporsions.
    image

  2. There were more problems, but them was on editor and harder to reproduce. Like changing root bone, then trying to create new Mask, sometimes the root bone change is not updated until you create mask, delete mask and create again. Sometimes you need to hcange root bone several times. I was not able to find correct sequence to reproduce these, but layers with mask should be reviewed by someone a bit.

I created forum post about it as well:
https://forum.playcanvas.com/t/confusion-about-animation-blending/35772/9

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.

Research direction

Start by reproducing the layer and additive-blending cases in the linked PlayCanvas projects, then inspect the Anim component behavior for layers, masks, and entity/render relationships. Compare the reported layer names before and after assignAnimation and the model scaling when Render is on another entity. Done means the reproducible cases are isolated and corrected, with the mask-editor behavior separately confirmed or documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
game-dev
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.