Public blueprint function

Hi, I’ve been searching for a while now and I cannot seem to find a way to call a public function based on the way I have my project set up.

I have a “GameController” blueprint that is loaded but does not physically exist in the level so nothing can collide with it etc to cast to it.

I then have “Enemy” blueprints that do exist in the level. When the enemy dies I want it to call a function in the “GameController” that will calculate the score based on the type of enemy calling the function.

My problem seems to be getting a cast to the “GameController”. All of the examples I have found require the enemy to have collided with something to pass the “castTo” functionality which I cannot do.

I hope this makes sense and that someone is able to help, this is killing me now.

Thanks all.

Thanks for the quick reply. I think this should work for this circumstance, I will try it and review your answer. However, in a more general term for larger projects is there no way to have a public bp and reference it in other bps? I am thinking more along the lines of how you can have a public script and call them.

Bps are seeming a little restrictive otherwise.

Thanks again though.

There is a special blueprint class called a Blueprint Function Library you can use for that. For your instance, however, it makes sense to use either or both the game mode blueprint and the level blueprint as a controller. UE4 was built to take advantage of those as controllers.

If this answer solved your question, please mark it as answered. Thanks!

Sorry I should have posted back, I found a way to get my gameController linked up which I needed to allow me to interact with objects in that bp that were in the level. Your suggestion seemed to make sense but kind of answered a question I didn’t ask. Thanks.

For anyone this might help in the future. I ended up using a “get all actors of class” and then casting that array and using that as a reference to the blueprint I wanted to call the function in.