Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to call a function from another class in a widget blueprint?


I'm trying to call a function from the player controller blueprint by pressing a button in a widget, but I have no idea how to do this. I have a OnClicked function in the widget blueprint where I want to call the function "LineUp" from the player controller: alt text

Thanks for any help:)

Product Version: UE 4.16
bpscrnshot.png (53.0 kB)
more ▼

asked Aug 20 '17 at 02:54 PM in Blueprint Scripting

avatar image

1 1 2 1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

On your widget you would need a reference to the Player Controller. This is usually achieved by using Get Player Controller node.

alt text

Then cast the Player Controller to your custom class. After the cast you can call the Line Up function.

capture.png (62.5 kB)
more ▼

answered Aug 20 '17 at 04:09 PM

avatar image

36 1 5 8

avatar image CptCollapse Aug 20 '17 at 04:46 PM

Hi LupenWonse, thanks for your answer. I've tried your suggestion but it doesn't work:( the cast fails. If I would reference a blueprint, other than the player controller, what would i put as the Object input?

avatar image LupenWonse Aug 20 '17 at 05:21 PM

Well if the cast fails than your current player controller is not using your custom class. See this page under Game Mode which explains how to setup a custom controller for your game,

If, however, you would like to reference another blueprint, you would need to somehow store a reference to the object in question. You can do that by defining a variable in your Widget and manually assigning it. Otherwise it is possible to find actors in your level, here is the docs

avatar image CptCollapse Aug 20 '17 at 07:04 PM

oh I forgot to assign the custom player controller, thanks a lot mate you really helped me:)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question