How can I call an event from another Blueprint?

Hello everyone.

I am trying to create some sort of resource respawning area where each time some of the trees are chopped, it calls another BP in charge to check and spawn a new BPTree_xx on that area.

I created the following Event hit, that calls an event dispatcher called CutTree, and then the BPTree_xx is destroyed

Then, inside the BP_SpawnableArea, I got the following so I can bind that event from the TreeBP to the nodes that will come later on.

The problem is that I have been trying everything and the cast always fails.

I’m getting crazy with this. If you guys think there is another way to call an event from another BP, please, let me know.

Things to note:

  • The TreeBP_xx is a child of BPTree
  • There are three different BPTree_ (01, 02, 03) each for a variation of each tree, but for this test I am just working with one of them
  • I get this message on the compiler → ‘object’ is already a ‘BP Tree 01’, you don’t need Cast To BP_Tree01 .

I’ve also tried using an interfaceBP to try another approach with no luck either

The text after calling the Interface is displayed, so it is not a problem there (the tree is also deleted)

But it doesn’t display the “Timber” text that it should display if the interface thing would work

Can you show where you got the reference to the tree? If you’re new to Blueprint, I’m guessing the tree reference is empty :slight_smile: This is causing Cast to fail.

Hey @ilimkyuusu thanks for the reply.

What do you mean by “where do I get the reference to the tree?”

When running the game, a certain amount of BP_Tree spawn on the area limited by the BP

This would be the BP_Tree content

And this would be the content of BP_SpawnableArea, where the TreeActors are called through the Actor Array so I can add multiple BPs and then later spawn them in the world. So I guess they are being references as they spawn nicely when running the game

I don’t know if this answer what you asked me?

Creating a variable does not do anything on its own, you need to assign it value, too. When you spawn something you can:

image

But, when using dispatchers the way you do, there is no need for a hard reference at all, I would actually get rid of it and just:

Now you can just destroy the tree (without even calling a dispatcher) and the spawner will receive the custom event call with the reference of the tree that was destroyed.

You also do not need an additional custom dispatcher. Actors already have a bunch and this onDestroyed will work well here.


Bind the OnDestroyed here:

image

Use Assign to automagically create a custom event with the correct signature (pins with types). The best part here is, that you do not need to store ActorBP_Tree reference anywhere. They all bind to the same custom event and each will execute individually.

1 Like

You are really a life saver, I was getting crazy. This solution is much better and much easier to understand, thanks a lot.


Then I was already referencing the Tree Actor. On the class array I had the three BP added and, in some of the many tries to make the dispatchers work, I was getting the actor from those classes to get inside the Target from the bind with no sucess.


Thanks so much for the help, for the clarity and the effort on taking so many screenshots and the video to explain that

1 Like