Using animations from variables in Anim BP?

I would like to have a set of animations (montages and blendspaces) that would control my character. Instead of hardcoding animations in animBP, I’m hoping to use animations from variables. However I have not had luck yet. I would love to use animBP as it contains very powerful tools for blending animations.

Lower body animations (idle/walk/run and crouching) stored in 2 properties of the character

UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Animation)
UBlendSpaceBase* MoveNormalAnim;

UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Animation)
UBlendSpaceBase* MoveCrouchAnim;

Other animations would be set for upper body into each item available in game.

UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Animation)
UAnimMontage* EquipAnim;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Animation)
UAnimMontage* IdleAnim;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Animation)
UAnimMontage* UseAnim;

For example when I try to pull the lower body blendspace into animBP it doesn’t seem to understand it at all. See the screenshot.

So what to do…? Should I just give up and accept my fate that I can’t have animations dynamically from variables/properties?

So no-one has tried on dynamically setting the used animation in anim BP? Or is it just plain impossible?

Does anyone know what type of object the editor uses when it shows dragged blendspace in the anim BP? I have started on looking to editor source, but it’s most likely too long road to follow… At runtime it should make no difference what animation sequences it evaluates as long as they match to same skeleton?

Actually I think it’s possible. According to your screenshot, I think you should cast your character blueprint in the event graph instead of the anim graph.

For my game, I use the EventGraph from the animBP to get all the variables and let the AnimGraph uses it. For example, I use the EventGraph to get 2 variables (forward and side), and then use those 2 variables in the AnimGraph.

I don’t think I can explain it as well as the video, so I really recommend watching it.

[- YouTube][3]

Hi and thanks from your example. For me it looks like that you have pulled only variables containing input values for a blendspace. I’m actually trying to get the blendspace (or other animations) itself from a variable.

I was looking more into the editor and I will try to create my own editor node(s) with the instructions given here A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums . A node that would extend the existing blendspace, animation montage and so on, but they would read the animation dynamically at runtime (and have a predefined one for editor).

Found a solution to this. You can grab a blendspace into anim graph and the from its properties you can show the blendspace as a input which you can pin the input you want. Cheers!

Could you please provide more details? Can’t do it myself.

While this is quite an old question I just stumbled over this myself and this was the solution. So in your locomotion graph of one of your states just drag any Animation sequenze you already have in it and link it up to the Result “block”. Then click on the Sequenze block you dragged in and look at the settings ( bottom right of the window). Here you can then check the checkbox of the first first property called “(As Pin) Sequenze” to make it show up as a pin in the graph. Now just hook up your animation Sequenze variable to it.

1 Like

Yeah nice, it worked perfekt!
Thx for this solution

  1. Drag and Drop a some animation into anim graph
  2. Expose the animation sequence pin (Look to the right side window, details panel?)
  3. Now you can attach any animation you want to it.
  4. After exposing the animation, I have attached Current Idle anim (Whatever it maybe at run time) to the Play Animation sequence node.

1 Like

When would one set the “current idle anim” var though? in a setup where you have potentially endless weapons and you can switch between them at runtime (and the individual animations are associated with the weapon obj), i found that you have to set the vars inside the anim blueprint on tick or on begin play. i cant set it once inside my controller or even pawn once i switch the weapon. Is there a more elegant solution to this problem?

Thanks

Many ways do it.

Create a Data table called Weapon DB. This will have all the details regarding the weapon, such as bullet speed, bullet damage, Idle animation etc.

Create a function called SetCurrentIdleAnim in your animation blueprint.

When you call your switch weapon function, grab the animation associated along with the weapon (From the data table) and pass it to SetCurrentIdleAnim.

By doing this, you send the current idle animation everytime you switch the weapon instead of polling it in a tick function.

Hope this helps.

oh yes the event based approach works as well. My problem was the multiplayer part. If anyone has the same issue: The server can’t change the client’s animation! its always a netcode problem, makes life so much worse :smiley:
thx

Holy smokes, this is EXACTLY what I was looking for and so I’m adding this comment to increase it’s visibility in any way I can. Thanks, you’re epic, don’t ever let anyone tell you otherwise