x

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 set actor int variable from button widget's OnClicked Event.

4.8.3

I have an actor which has a static mesh and widget component. Currently im dynamically adding button widgets to the widget component via a for loop. The ForLoop gives the button an index which also sets the column (uniform grid panel). I have set up a OnClicked Event where the button which prints out its index.

I am struggling to understand how to use the OnClick event and the index inside the widget blueprint to set a variable back in the actor which is an integer (meshIndex).

Do I have to set up a custom event inside the actor?

Product Version: UE 4.8
Tags:
more ▼

asked Aug 26 '15 at 08:13 AM in Blueprint Scripting

avatar image

Baserage
28 6 10 12

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

2 answers: sort voted first

There are a couple different ways of handling it.

You could just store a reference to the owner Actor inside of the widget. When the onclick is pressed, it just calls the function directly from the stored reference. That seems to be the simpliest way of doing it.

Hope that helps.=)

more ▼

answered Aug 26 '15 at 12:18 PM

avatar image

Devero
2.3k 114 61 233

avatar image Baserage Aug 26 '15 at 11:22 PM

Hi, thanks for your reply.

Ive set up a function which takes in the int value of the button which is pressed which sets the meshIndex int, but it doesnt work. The function will only print the meshIndex at begin play which means the button isnt changing the value?

alt text

alt text

alt text

avatar image Baserage Aug 26 '15 at 11:45 PM

I just added an OnClick event for the button inside the actor which sets the mesh index. Its just for testing so ive got int + int plugged into set meshIndex which when I press a button it returns a value of 1. However, the mesh doesnt change when I press play? How is that possible, the mesh selection is dependent on the int.

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

So I worked it out, I just had to add another int variable in the event graph with another OnClick event referencing the button. Thanks Devero, the function also helped with the process :)

more ▼

answered Aug 27 '15 at 12:35 AM

avatar image

Baserage
28 6 10 12

(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