How to store a pointer to a Blueprint actor?

I would like to store a pointer to my player Blueprint in order to call one of its functions. However, I am unsure of how to cast the player pawn to my custom class, as it always returns an undefined error. I assume that it will be more complicated than simply including a header file, so does anyone have any suggestions for a C++ noob like me?

same as blueprints. When you store an actor or any object into BP variables you are storing a pointer (instance) of its class.

thing is how you access to the blueprint actor and can be in many ways…it depends on what do you want to do with that actor…you can do anything that belongs to AActor class (like change transforms) but if you want to do specifics things is possible you must cast it.

If the functions you want to call exist only in the blueprint, I’m afraid you can’t access them in C++.
What you can do is create a base C++ class for the blueprint you want to access. E.g. if your blueprint is of class Actor, create a C++ class derived from Actor. Then you can select the new C++ class as the parent class of your blueprint.
In your new C++ class, declare functions marked with UFUNCTION(BlueprintImplementableEvent); these events you can use in your blueprint alongside or instead of your custom functions. And you’ll be able to call them from other C++ classes.

3 Likes