Best way to trigger event on a BP when a variable (integer) has changed on another BP?

I have an integer variable (named CubeAmount) set up on my BP_FirstPersonGameMode. I have successfully modified the gun in the unreal FPS template project to spawn a BP Actor named BP_Cube (a basic BP Actor with a Cube static mesh component) at the point where it’s projectile hits something. On the spawned cube BP I have successfully set it up to increment CubeAmount by 1 on EventBeginPlay so that CubeAmount essentially equals the amount of cubes actors the player has spawned in the level with the “cube-spawning” gun. This is all working fine.

I have placed another BP Actor in the scene (BP_Sphere) and I want to trigger events on BP_Sphere blueprint when CubeAmount has reached certain amounts (let’s say 5, 10 and 15). I can’t figure out the best way to do this. I have tried using EventTick and checking CubeAmount is equal to 5, but this of course constantly triggers when CubeAmount is at 5, and this doesn’t suit my purpose (I also understand this is quite inefficient).

I have also tried an Event Dispatcher on BP_Cube, and tried binding/assigning the dispatched event on BP_Sphere to have BP_Sphere check CubeAmount every time a BP_Cube is spawned, but tutorials I’ve followed don’t explain clearly how I can bind/assign to my spawned BP_Cube. I may very well be doing this wrong, but I also feel like there must be an easier way for BP_Sphere to check if CubeAmount changed and check what CubeAmount is at that point only.

Many thanks for the help. I am new to Unreal and Blueprints, with no coding experience and only youtube tutorial knowledge.

You can simply cast to the other blueprint by using the Cast To node, drag the blue output pin of the node out (which should be named something like “As Example_BP”), release it on an empty space, type the name of the custom event that’s inside the blueprint we’re casting to into the menu that pops up, and connect the white execution pins.

It should look like this:

Additionally, if you’re not sure what to plug into the Object pin of the Cast To node, you can use this:

Hope this helps! :innocent:

For something that simple we do not need dispatchers, variables in the actors or anything else, not really. When you spawn the cube:

  • get Game Mode
  • cast to your Game Mode
  • increment the integer

That’s pretty much it.


If you want to be proper, use a Custom Event / Function instead of the ++ node, and have the GM modify its own variable. This will then allow you to execute additional script - like updating the UI, for example.

Good luck!

1 Like

Thanks, this was super helpful and I got it working!

This worked perfectly for incrementing the variable, thanks!