How do I BPI pass a variable in Anim Notify to Char BP? [How to Hit trace in Anim Montage]

UE4.27
Can you please help with BPI, havent found exact answers.

How do I setup a BPI to pass a variable (Hit Actor) from Actor/Object 1 (Anim Notify State) to Actor 2 (Character BP)? (To not use CastTo).

Im using Anim Notify State > in Anim Montage… so I can use the duration bar to visually see when my animation body-mesh should be hitting something (it is a leg spin kick).

Thus I put the Hit trace code in Anim Notify State (Actor 1).
[as see in a YT vid UE4 Attack Collision Trace Effect - Tutorial - YouTube]

But I want the code for playing the Anim Montage (on the Hit Actor = variable), in my Character BP (Actor 2), because I have other related code there.

  1. In BPI, I dont know whether to add an Input or Output as the variable…

  2. In Actor 1, do I use BPI > Interface call or Message Node – to collect/send the variable?

  3. And in Actor 2, which BPI node do I use to receive the variable from Actor 1?

  • Also Im confused because I am using the Tick return Function that is already in Anim Notify State. (Because my trace code is in there. I want it persistent on Ticks right.)

  • But I cannot edit the Return Node. Do I need to pass the variable to Return Node? Or only to the BPI node (that is inside Anim Notify State)?

Please help with pics, thanks.

Here’s the file/code to help you help me faster.
Unpack into Content folder (Has the BPI asset and Anim Notify State):
00pub.rar (21.4 KB)

Any ideas? Search found that many ask how to BPI pass a Var from Actor A to B. Yet no exact answers.
I even asked last year, yet didnt get answers for the 3 setup-situation questions above.

Cant BPI pass a variable between 2 actors? Am I wrong?

You can pass variables just fine. Problem you are going to have is AnimBP to Character.

Execution flow on the character class is:

Character Event Graph → Anim BP Event Graph → Anim BP Anim Graph.


Any variable coming from anim BP to character will be overwritten in character on tick next frame.

Thanks for the reply.
Are you saying that an “Anim Notify State” Asset (or Anim Montage Asset) is AnimBP-tier order of operations? (And thus youre saying it gets overwritten by CharacterBP final Order of operations?)
I just need [Anim Notify State code] to pass the Var to CharBP for 1 frame, because then (in CharBP) I would set that Var to = the equivalent Var2 that is already in CharBP.

And I tested [Anim Notify State code] with a Print - it fires multiple times (many frames). So what does that mean for my Var?

  • If AnimNoteState sets Var > Pass to CharBP, set it as internal Var2, repeat 6 frames - then what would be the final Var/Var2 value:
  • None or the [Hit character] that I desire?

Anim Notifies call events in the AnimBP class. Values cannot be passed from From animbp to character bp.

Might not be a bad idea to move the trace stuff out of the notify and onto your character.

Notify state could simply call the function which does that via a message to the mesh comp’s owner. The interface function would have an input pin for “attack type” or something (maybe an enum?) which selects a bone to trace from.

When that hits something, send target a message calling a “got hit” function or some such with a reference to self in one pin (if target needs it), and attack type as the other. Attack type would then be used to select which reaction montage to play.

Doing it like that make it easier to add any damage modifiers (via character stats/powerup items/whatevs), and having single functions that handles tracing/damage would be easier to change later. Likewise, adding new notify states would just be a matter of duplicating and changing the attack type var.

Anim notify events can call events/bpi events on the “hit” character.

Just cast to hit character, check “does implement interface” → call BPI event.


But like Spirit said, trace hits or any “logic” outside of animating your character should be handled in the Character class itself.

Give us some details of what your character is doing and what you want to happen. We can more than likely guide you to a more proper solution.

@illspiritx @Rev0verDrive ok thanks for the replies.

  • [I’ve been reformating my code to post. Encountered a problem, so I made a new thread on that specific topic (it also shows my setup pics for what I explain below).]

How do I split AddUnique array - to Play Anim Montage once per index?

@illspiritx made good points to consider. So I will clarify what I want to do:

  1. I have 90% of the Attack code in Player Character BP (while AI character is a child, thus uses the same logic).

  2. I want the brain/logic driven by the Player’s CharBP - meaning when I press a key, it triggers the code in Player’s Char BP (not AI BP).

  3. The reason is that I am using a DataTable to set 10 vars related to the Player’s anim montage to play, the Target’s reaction anim to play, the distance required, etc.

  4. But for #3 to work in my Player’s CharBP, I have a Hit Target var, which I need to set.

  • Update: I no longer wish to get this Var from the constant Tick-Hit [Notify State] (that is in the Anim Montage of my Player’s attack)
    ** old: From NS, I used to wish to pass the Hit target Var > to my Player’s CharBP >
    ** then I pull the same DT row (that chose the Player’s anim montage) >

    ** to get the matching Target reaction montage > and thus [Play Anim Montage] on Target enemy, from within Player’s CharBP code.
  1. #4 is very complicated and my CharBP is getting slower to compile, save, make backup copies. Thus I wished to use the NS hit code to Compartmentalize my code changes (makes it easier to backup, duplicate a NS asset instead of CharBP).
  2. But [Pro to put the Hit code in CharBP]: @illspiritx is correct about “adding new notify states would just be a matter of duplicating and changing the attack type var.” Now I use DataTable to feed the different Hit Bones to use for each attack > into the Hit function in CharBP [Pic 6].
  • But [Con to have one NS that handles all, and ‘change attack type’]: Is that I dont know how to feed the [NS tick Function] a variable? “Received Notify Tick” is an Epic Function, and they dont let me add Input pins?

  • Update: now I need to know how to BPI send a Var from CharBP to NS?
  1. Update: I posted my code pics at the link above. I’ll paste here for ease:

[Pic 0 below - the BPI setup now]

[Pic 1 - Anim Montage contains the Anim Notify State duration]

[New method: Pic 2 - ANS that calls BPI Event in CharBP - no var transfer needed, just call Event.]

[Pic 5 - CharBP where BPI event was triggered to start by ANS]

[Pic 6 - Hit function]

I take it you’re grabbing the bone name for traces and the reaction montage from a data table when you initiate the attack? If so, yea, you really only need one generic notify state. Also, don’t need to cast a message call.

That function could probably do the trace itself with the existing vars (assuming there’s no animation cancelling shenanigans), add all unique hit actors to an array, and immediately send them all a message to do a reaction function in a loop. Don’t need to cast or ignore anything here either, as only actors with the interface will get message. Could maybe optimize with a “does implement interface” branch though I guess.

If the trace function is only ever called by notifies, probably don’t need return pins on it, so just clear array and move on. Removing actors in a second layer might be freaking out since notify state is calling every tick?

The new reaction interface function would need the montage as an input (or use attack name if chars can have different reactions to lookup), and an actor pin for the instigator plus a float or something to do damage. If there’s no outputs on it, you can implement as an event and use timers or delays and a gate to add cooldowns as neeeded.

Cooldown or no, is probably better if the hit character is deciding to animate or not.

If character bp is getting bloated, could also move some of this to a new component class. Might come in handy one day if you want to punch actors not based on main character or its anim bp.

1 Like