state machine question

i am trying to create a state machine that transitions between two animations, flying and gliding, for a bird relative to time elapsed. i want the animation to start as flying, for 30 seconds, and then transition to gliding for 10 seconds and then in a loop like this indefinitely. i cannot find any resources anywhere describing how to do this, please somebody help me with this i have been pulling my hair out for hours now trying to find the solution. tyia

From your entry try creating two states. Call one Gliding and the other Flying. you can do a number of things here, but for simplicity you can drag in your animation and connect it to the output animation pose. Or you can use a Random Sequence Player and have multiple animations. From each state drag a transition to the other. Click on each transition to make a transition rule. You can get time remaining from your animation with some “And” “Not” “Or” to get your desired result. Something like this:

In your instance, you may have a flying animation that lasts 30 seconds. Like in the screenshot if the time is nil such as less than “0.1” and you have a boolean set up that might say “NotFlying?”, then the rule will be accepted and you can then transition to “Gliding”. There you’d play your animation and then on the out transition of that state get time remaining in the opposite animation and from Glide To Flying with less than “0.1” and a “Not” or “Or” with a boolean that says “NotGliding?” and then it will be allowed to transition back to “Flying”.

There are a lot of ways you can do this, but as far as looping these you could bind a timer to an event in your character blueprint and have it to where it changes the booleans periodically and the animations should change accordingly. Before this can work the animation blueprint must be set up correctly. You have to have logic in your character or controller blueprint that executes the booleans in any number of ways. There are a ton of videos on this on YouTube.

You make the variables in the character blueprint and then in the animation blueprint that the character has been assigned you “get” these variables and promote them to a variable and string them down your execution chain in the Anim Blueprint.

This is pretty general as there is so much you can do there. Sorry about that. Most of the easier functions just need a simple boolean in the Anim Blueprint to make changes to the animations. If you wish to add control to the animations in the “state” you’d need Blendspaces and those can get complicated, but they’re manageable.

i will try this today, thanks so much for getting back to me with such a detailed answer i never would have figured that out on my own haha

You’re welcome. There are a lot of videos on YouTube that tackle these issues. Sometime they’re hard to find because they’re shrouded in different kinds of projects, but ultimately they all have to solve this issue with the state machine. Lol

This might work:
Create an int in the animation blueprint called animationState or something like that. On the bird character blueprint, create a custom event called something like change animation state. There is a node called Get Anim Instance. From there, search for “Set AnimationState.” Set it to the first state, then add a delay and set it again to the second state. Then make another delay and after that, call the custom event itself. That will create a loop.

In the Animation Blueprint, there is a node called Blend by Int. You plug the animations into their inputs and the int into the int input. Inside the state in the state machine, or even in the Anim blueprint itself with no state machine, you can switch between these two animations, controlling the int value automatically on an endless loop from the character blueprint.

To start it, call the custom event from begin play and it should loop endlessly. At the start of the custom event, you can put a branch and make a boolean to control if it plays to not, like if the bird dies or should spawn at some specific time. From the false, you can then call something else, like attack, flee, die, play dead etc.

My all time favourite method uses an enum and is explained here: (At 9:40 minutes)

You might have to watch part 1 if blueprint interfaces are new to you.

If a real programmer stops by and sees this, feel free to shred my method for the character blueprint and replace it with something better.