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?
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 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.