How do I call a function from another Blueprint?

I’m working on an RTS game and I’m having trouble getting the controls to work correctly. I cant figure out how to call a function from another blueprint. What is the best way to do this?

Here is the function that needs to be called

And here is where I’m trying to call it in the Controller

What is the issue you are having? Are you getting ‘It didn’t work…’ debug output?

This is how I do it usually and it works for me. Isn’t the function gettting called? Are you sure the Actor variable in second blueprint is pointed to an instance of PlayerCharacter blueprint?

In any case, You could move the logic for Mouse Wheel UP and Down to PlayerCharater itself.

I followed this setup in the link below… although none of those ways worked for me.

https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/BlueprintComms/index.html

I did try setting up the logic for mouse wheel inside the character, but then I can’t see my mouse cursor to select units.

How do I point the Actor variable to an instance of the PlayerCharacter? In the link above, they used a TargetBlueprint_C variable, which I couldn’t find.

Ok When you have a variable of Type Object (like Actor, Pawn…), you can only set its value after instantiation.

So in your case, you should set the Actor variable to a refernce of PlayerCharacter.

I am assuming that you have only a single PlayerController. In this case you don’t really need the Actor variable; instead do this:

Within the event handlers (wheel up and wheel down), Use ‘GetControlledPawn’ node to get a reference to the Pawn being controlled by your player controller. Cast its output to ‘PlayerCharacter’ blueprint class. Everything else is the same.

However if you logic is different and you want to call the function on some other PlayerCharacter object otehr than the one controlled by you, you should first select this instance first and store a reference to it (how you would select it is dependent on your logic), And make no other modification to your blueprint.

Try closing the project and opening it again. If you have an error on the function, same as here;

then what you need to do is use a custom event to fire the function…

Well it seems to work now. Using the “GetControlledPawn” node seemed to do the trick.Thanks!

Interesting… I think I might have to use that in the future.

Glad it worked.
Please mark this thread as solved.