I have a project that uses an animation blueprint to control animation of a character class, but I have a very large selection of animation sequences and it’s really messy to have playback nodes for each sequence compiled into the animation blueprint and using an enumerator to switch between sequences.
What I’d like to do is be able to give the animation instance a reference to an animation sequence and just have it play that sequence. This way I could add animation sequences to the project without having to add a bunch of logic to the animation class. Is there some way to accomlish this?
OK so with out context we get into the area of game theory and design.
A assumption as far as animation BP’s goes is all functions and state changes needs to be included as part of the controlling animation BP when in fact the animation BP can be switched at run time based on the required animation know as context based animation.
To get a broad view as to what is context based animation just do the Google thing as it is a design pathway that’s been around for years but the simple version is a state change is only required once the animation requirements is triggered unique to the current game state.
For example a ladder climb has a limited number of state requirements limited to the “context” of climbing a ladder so the ability of 8-way movement is not required until the player leaves the ladder and is once again with in the “context” of 8-way movement requirements and state changes. Another popular context is driving a vehicle or riding a horse.
The benefit of a context based approach is your animation states can be easily scaled up by the iteration process rather than having a do all animation BP that as you say gets messy based on the more your expect it to do.
Another option is the use of components which can be added directly to the controller and with the introduction of the game play plugin system as it should allow you to switch then animation context requirement based on the event trigger.
Sounds more like you just need to use Montage based on your opening post.
You can also use a variable:
Second that.
Altough you’ll run into trouble if you retarget your AnimGraph to a new skeleton. The “Play Animation Sequence” node somehow keeps the original skeleton and will through an error that your Sequence is using a different skeleton.
I wasn’t aware it was possible to use a variable, when I type play in the animation blueprint it only brings me play commands for specific animations and one random command.
Are there any conditions that must be met to be able to use a variable? I still don’t see that option when I edit my animation blueprint.
It’s probably not fast path approved, but you can expose the animation pin inside any animation created when you drag into the state machine.
It’s in the details panel where it let’s you drop down and select the animation.