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
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 This is causing Cast to fail.
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
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:
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.
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