#[SOLVED] Animation Tree working only half of the time.

1 messages · Page 1 of 1 (latest)

tight kernel
#

I'm making an enemy with a state machine, and I'm trying to set it up so that if it comes close enough, the state swaps over from a Chase state to an Attack state.

In the Attack state, a random number is picked at enter(), the physics_process() counts down that number, and when it hits 0, the attack animation should play in the correct blend_position and then swap back to the Chase state.

However, as you can see in the clip, the attack animation runs only half the time. Does anyone know if I'm doing something wrong or how to fix this?

rigid lily
#

So on entering the state, it will wait between 2 and 4 seconds before attacking? Wouldn’t it be desirable to attack immediately when entering? Why wait?

#

Decrementing the timer only when it is above zero might also be adding a subtle bug. Perhaps it is meant as a cooldown?

#

Can’t see how the states switch and the video has the player also moving in and out of range, so I assume it is changing states at a certain distance. You might also want to consider a distance buffer to avoid changing states too quickly and resetting timers

tight kernel
#

Yea you're right, there's still a lot of stuff to improve on the whole player experience side. Ideally I want the enemy to do a dash aswell when it does its attack move, which is why I added that timer. Of course I need to tweak the values, but for now I just wanted to see if I could get it all working alright, and already I can't seem to get the animations working correctly.

rigid lily
#

Everything is there, it’s working - it just needs tweaking as you say. I’d attack when entering (create a function the does the animation bit, call it) and then set the timer. Check the timer in process and when < 0, call the attack function and reset the timer ( += new random).

tight kernel
#

Well the timer is set every time the state is entered, so that's already being reset. I've tried swapping the animation tree commands for a function already aswell, which gave the same results. I'll keep on trying things until something sticks.

#

I think what I've been able to figure out is that my idle animation consists of two frames, and it can only switch to the attack animation on the first frame, and not the second frame, or the last frame for that matter. Guess I have to find a workaround for that

tight kernel
#

[SOLVED] Animation Tree working only half of the time.