Anim State Graph Closed Beta - Feedback here!

More information about the Animation State Graph and how to sign up for the beta can be found in this thread: Anim State Graph Closed Beta - Sign up here!

Please post feedback and issues here :slight_smile:

2 Likes

Hi!
Is there any way to modify the speed of a state at runtime?

Hi @Javier_Heras

The anim component exposes the speed property which controls the speed at which the currently playing state will play. The individual speeds of states though are currently set at load time. Would that meet your requirements? This is a feature we could explore further.

3 Likes

For the moment is enough, thank you!

For any reason when I destroy an entity with a StateGraph, all other entities with the same state graph stop work. They return to T pose. The model, the animations and the state graph are assigned by code using the bitmoji library to create the assets. I have made sure that it is not destroyed by a event when I destroy the entity. The used classes are glb-converted-assets.js and utils.js

The code:

// Load model
 this.app.glbConvertedAssets.load(this.modelAsset, function (err, asset) {
        if (err){
            console.warn('Cannot load model asset: ' + err);
        }
        else {
            self.setModel(asset);
        }

MyClass.prototype.setModel = function(modelAsset)
{
    if(this.modelEntity.model.asset === null && modelAsset !== null)
    {
        this.modelEntity.model.asset = modelAsset.resource.model;

        var meshInstances = this.modelEntity.model.meshInstances;
        for (var i = 0; i < meshInstances.length; ++i) 
        { 
            var mesh = meshInstances[i];
            mesh.material = this.material.resource;
        }
    }
};

// Load animations

let numAnimationsLoaded = 0;

    for (var i = 0; i < this.stateAnimMappings.length; ++i) 
    {
        let mapping = this.stateAnimMappings[i]; // the animations
        if (mapping.animAsset) 
        {
            this.app.glbConvertedAssets.loadBitmoji(mapping.animAsset, function (err, asset) {
                if (err)
                {
                    console.error('Cannot load animation asset: ' + err);
                }

                numAnimationsLoaded += 1;
                if (numAnimationsLoaded == self.stateAnimMappings.length) 
                {
                    self.addAnimations();
                }
            });
        }



MyClass.prototype.addAnimations = function () 
{
    this.modelEntity.anim.loadStateGraph(this.animStateGraph.resource);
    var locomotionLayer = this.modelEntity.anim.baseLayer;

    for (var i = 0; i < this.stateAnimMappings.length; ++i) 
    {
        var mapping = this.stateAnimMappings[i];
        if (mapping.animAsset) 
        {
            var containerAsset = this.app.glbConvertedAssets.get(mapping.animAsset.id);
            if (containerAsset == null)
            {
                this._log.error('Animation ' + mapping.animAsset.name + ' not ready');
            }
            else
            {
                locomotionLayer.assignAnimation(mapping.stateName, containerAsset.resource.animations[0].resource);
            }
        }
    }
};

This code works fine, but for some reason when an entity is destroyed all those that share the state graph stop working. Any idea what the motive may be?

Try using https://developer.playcanvas.com/en/api/pc.AnimComponent.html#stateGraphAsset instead of

    this.modelEntity.anim.loadStateGraph(this.animStateGraph.resource);
1 Like

Works the same as loadStateGraph, thanks. But it doesnā€™t solve the problem.

further console.log(this.animGraph.baseLayer.activeState);
returns different states over time. The anim is working it seems. But not for the model.

image

Would it be possible to have a simple repro of this that @Elliott can investigate please :slight_smile:

I found a few bugs:

  1. Looping doesnā€™t save.

  2. you can right-click any state and the bar will stay there, same goes for transitions i think.

  3. Its possible to break the anim state asset by unlooping the first state

  4. Setting the speed to negative causes it to not play. Should play in reverse.

3 Likes

Itā€™s possible to break the anim state graph asset to an unrecoverable state in which the editor refuses to open it so canā€™t fix the mistake.

Stack trace from the editor:

captureconsole.ts:73 TypeError: Cannot read property 'name' of undefined
    at pcui-graph.js:66
    at Array.forEach (<anonymous>)
    at pcui-graph.js:66
    at Array.forEach (<anonymous>)
    at new t (pcui-graph.js:66)
    at a.value (pcui-graph.js:66)
    at i.value (pcui-graph.js:66)
    at pcui-graph.js:66
    at Array.forEach (<anonymous>)
    at i.value (pcui-graph.js:66)
    at new i (pcui-graph.js:66)
    at AnimstategraphView._createGraph (editor.js:74127)
    at AnimstategraphView.link (editor.js:74268)
    at AnimstategraphAssetInspector.openFullscreenMode (editor.js:75994)
    at AnimstategraphAssetInspector.link (editor.js:76067)
    at editor.js:73335
    at Array.forEach (<anonymous>)
    at AssetInspector.link (editor.js:73322)
    at Editor.<anonymous> (editor.js:86046)
    at Editor.Events.emit (events.js:57)
    at Editor.<anonymous> (editor.js:56497)
    at Editor.Events.emit (events.js:57)
    at evtChangeFn (editor.js:24965)
    at sentryWrapped (helpers.ts:87)

Any situation where thereā€™s a transition loop between 2 states without conditions causes this.
image

2 Likes

Another thing. I donā€™t know if this is a bug or maybe Iā€™m doing something wrong (a more detailed documentation would really come in handy) but it seems like transitions canā€™t be interrupted? At least in this case:

I assumed that the construct below should always fire on the trigger but that isnā€™t the case.
ANY--[ Duration 0, interruption: Prev, Condition: trigger ]--[Attack]

The attack animation is delayed given enough triggers and I had to resort to this:

anim.setTrigger('Attack', true)
if (anim.baseLayer.transitioning)
    anim.baseLayer.play()

calling @Elliott

Thanks for reporting these issues. It looks like there was a bug when setting any state attributes which could affect looping / setting the speed / name. Iā€™m currently testing a fix for this now so it should be updated shortly.

Iā€™ve also updated context menus to disappear after 500ms of inactivity.

Thanks for sharing! Looking at the error this produces it seems to be related to the issue @Fus_ion raised. Iā€™ll release a fix shortly.

1 Like

Which transition do you wish to interrupt the [ANY > Attack] transition with? As youā€™ve set the interruption source to ā€˜Prevā€™ itā€™ll only look for transitions coming from the ANY state which in this case means only the [ANY > Attack] transition can interrupt itself.

Note that the interruption source sets a transition to be interruptible rather than setting the transition as being able to interrupt other transitions.

Hi, I have same problem, If I make 2 states without conditions when I back from scene and try to open graph again nothing appens, the anim graph panel doesnā€™t appear!

are there any errors in the browser developed console?

here the screen when I click the button ā€œopen graph editorā€:

Hi @dinof, thanks for reporting this. I wasnā€™t able to reproduce it with the steps you set out. Would it be possible to add me to the project that has the issue?

My PlayCanvas username is ellthompson

I understood! problem comes when you remove the flag from loop option at ā€œinitial stateā€
If I leave loop checked at ā€œinitial stateā€, problem doesnā€™t comes anymore. I can instead uncheck loop option for all other states without problems and witout errors in console.

I made a pubblic project: https://playcanvas.com/project/784703/overview/dino-bugtest--anim-graph-editor

1 - open: test scenes

2 - go to folder : anim graph editor

3 - you will find two graphs, only one can be opened (the one with loop checked at first state)