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?
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.
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()
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.
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!
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?
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.
@redka@dinof@Fus_ion A fix has been released to production which should address the issues/crashes you were experiencing when editing state attributes in the graph editor.
For example I want to prepare simple sliding door system which should be controled by a 2d button, so I need to prepare conditions of how sliding doors should open: speed of opening, length of movement of each door etc., so all this things I need to write in JS code which will be added to an entity in main editor of playcanvas, did I understand correctly?