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
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
Hi!
Is there any way to modify the speed of a state at runtime?
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.
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);
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.
Would it be possible to have a simple repro of this that @Elliott can investigate please
I found a few bugs:
Looping doesnāt save.
you can right-click any state and the bar will stay there, same goes for transitions i think.
Its possible to break the anim state asset by unlooping the first state
Setting the speed to negative causes it to not play. Should play in reverse.
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()
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.
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?
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)