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

**URL:** <https://forums.unrealengine.com/t/how-do-i-bpi-pass-a-variable-in-anim-notify-to-char-bp-how-to-hit-trace-in-anim-montage/1144800>\
**Category:** Blueprint\
**Tags:** unreal-engine, question\
**Created:** [April 26, 2023, 9:01am UTC](https://forums.unrealengine.com/t/how-do-i-bpi-pass-a-variable-in-anim-notify-to-char-bp-how-to-hit-trace-in-anim-montage/1144800 "2023-04-26T09:01:32Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![XxNotAGamerxX](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@XxNotAGamerxX](https://forums.unrealengine.com/u/XxNotAGamerxX)\
**Post date:** [April 26, 2023, 9:01am UTC](https://forums.unrealengine.com/t/how-do-i-bpi-pass-a-variable-in-anim-notify-to-char-bp-how-to-hit-trace-in-anim-montage/1144800/1 "2023-04-26T09:01:32Z")

</div>

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](https://youtu.be/R2OZlOHMOtY?t=423)]

 ![Inside Actor 1 (Anim Notify State -Tick Function)](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/1/9/b191571eeeaeb001cf12dea758ff775b5553ab3b.jpeg)

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](https://forums.unrealengine.com/uploads/short-url/m3WTcsz9h7zg0FuLahVlTEOBqsM.rar) (21.4 KB)

---

<div class="post-metadata">

**Author:** ![XxNotAGamerxX](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@XxNotAGamerxX](https://forums.unrealengine.com/u/XxNotAGamerxX)\
**Post date:** [April 26, 2023, 10:00pm UTC](https://forums.unrealengine.com/t/how-do-i-bpi-pass-a-variable-in-anim-notify-to-char-bp-how-to-hit-trace-in-anim-montage/1144800/2 "2023-04-26T22:00:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![XxNotAGamerxX](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@XxNotAGamerxX](https://forums.unrealengine.com/u/XxNotAGamerxX)\
**Post date:** [April 29, 2023, 9:36pm UTC](https://forums.unrealengine.com/t/how-do-i-bpi-pass-a-variable-in-anim-notify-to-char-bp-how-to-hit-trace-in-anim-montage/1144800/3 "2023-04-29T21:36:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Rev0verDrive](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rev0verdrive/32/907214_2.png) [@Rev0verDrive](https://forums.unrealengine.com/u/Rev0verDrive)\
**Post date:** [April 30, 2023, 6:21am UTC](https://forums.unrealengine.com/t/how-do-i-bpi-pass-a-variable-in-anim-notify-to-char-bp-how-to-hit-trace-in-anim-montage/1144800/4 "2023-04-30T06:21:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![XxNotAGamerxX](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@XxNotAGamerxX](https://forums.unrealengine.com/u/XxNotAGamerxX)\
**Post date:** [April 30, 2023, 6:45am UTC](https://forums.unrealengine.com/t/how-do-i-bpi-pass-a-variable-in-anim-notify-to-char-bp-how-to-hit-trace-in-anim-montage/1144800/5 "2023-04-30T06:45:39Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Rev0verDrive](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rev0verdrive/32/907214_2.png) [@Rev0verDrive](https://forums.unrealengine.com/u/Rev0verDrive)\
**Post date:** [April 30, 2023, 7:31am UTC](https://forums.unrealengine.com/t/how-do-i-bpi-pass-a-variable-in-anim-notify-to-char-bp-how-to-hit-trace-in-anim-montage/1144800/6 "2023-04-30T07:31:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![illspiritx](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@illspiritx](https://forums.unrealengine.com/u/illspiritx)\
**Post date:** [April 30, 2023, 7:57am UTC](https://forums.unrealengine.com/t/how-do-i-bpi-pass-a-variable-in-anim-notify-to-char-bp-how-to-hit-trace-in-anim-montage/1144800/7 "2023-04-30T07:57:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Rev0verDrive](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rev0verdrive/32/907214_2.png) [@Rev0verDrive](https://forums.unrealengine.com/u/Rev0verDrive)\
**Post date:** [April 30, 2023, 8:01am UTC](https://forums.unrealengine.com/t/how-do-i-bpi-pass-a-variable-in-anim-notify-to-char-bp-how-to-hit-trace-in-anim-montage/1144800/8 "2023-04-30T08:01:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![XxNotAGamerxX](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@XxNotAGamerxX](https://forums.unrealengine.com/u/XxNotAGamerxX)\
**Post date:** [May 4, 2023, 3:30am UTC](https://forums.unrealengine.com/t/how-do-i-bpi-pass-a-variable-in-anim-notify-to-char-bp-how-to-hit-trace-in-anim-montage/1144800/9 "2023-05-04T03:30:52Z")

</div>

@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?](https://forums.unrealengine.com/t/how-do-i-split-addunique-array-to-play-anim-montage-once-per-index/1153758)

@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]

 ![0 BPI Input setup](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/0/c/f0c2a1420768a49ec227f9ccb3ef5bcda3b893b5.png)

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

 ![1 Anim Montage - ANS duration](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/b/1/9b104396aec1f9477b6ae92df0534d335aa096e2.png)

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

 ![2 ANS - calls BPI in CharBP](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/f/9/3f96f2204016d5d79278e426bedd1462a6f21bb5.png)

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

 ![5 CharBP - BPI Event called - go in Hit Function next - then out to Play montage code](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/3/f/13f2b3d3c2b9fce2a07a1e39d8f8d357a5a4234f.jpeg)

[Pic 6 - Hit function]

 ![6 Hit function in CharBP](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/9/8/4987fc3d31067aced0cef104b66024f3f4b9ba44.jpeg)

---

<div class="post-metadata">

**Author:** ![illspiritx](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@illspiritx](https://forums.unrealengine.com/u/illspiritx)\
**Post date:** [May 4, 2023, 7:28am UTC](https://forums.unrealengine.com/t/how-do-i-bpi-pass-a-variable-in-anim-notify-to-char-bp-how-to-hit-trace-in-anim-montage/1144800/10 "2023-05-04T07:28:11Z")

</div>

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.
