[SOLVED] Unable to transition animations upon detection

Hi guys! I’m using the Anim for my enemy AI rigged by Mixamo, and I’d like to make the enemy move from Idle to Running once in the detection area of my AI Script. I’ve been looking on how to switch animation upon detection range but I can’t find any. The code I have right now only moves it from Idle and it floats for some reason :// Here’s my code and thank you in advance!! (suffering so much lol)
What I’m hoping for is: Idle (Initial state), Running (Once in player detection range), Attack(very near player)
https://playcanvas.com/editor/scene/1965707

Hi @jcatalan!

I expect to see something like the code below in the script of the enemy AI, but currently I found nothing in the script that controls the anim state graph of the enemy AI.

this.entity.anim.setFloat('Distance', distance);

You also need to check the anim state graph, because I guess the conditions of the transitions are conflicting.

Thank you so much! that part worked but now it’s not moving towards the player anymore, just showing the animation. hehe i’m trying to figure it out and i have the script for that but theres nothing :frowning: thanks again! <3

I see you have changed the way of movement, so this problem is not related to the topic.

ohh alright, my bad hehe :sweat_smile::sweat_smile: thank you so much for your help! means a lot :))

1 Like