[SOLVED] Get animation states and then play them

is it posible to get an animation state and then play it using an giving string if that will be matching to the gotten string kinda like this

const states = animator.getstate();
for(let i =0;i>states.lenght;i+=){
if(states[i].name===this.givenstring){
anim.play(states[i]);
}
}

this is a rough sketch but kinda like this

^^ biggest problem is how to get animation state from an ANIM

You can get the states for from the animation layer https://developer.playcanvas.com/en/api/pc.AnimComponentLayer.html#states

If you want to transition between states via code, you can use https://developer.playcanvas.com/en/api/pc.AnimComponentLayer.html#transition

Example here: Animation without State Graph | Learn PlayCanvas

1 Like

thanks! amazing help you have given me up to now

this link was perfect for what i needed

https://playcanvas.com/editor/code/841793?tabs=57840986,57840987