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"

Creating a system to change specified materials


I'm trying to use UE4 to do some arch-vis work. I need the ability to change between different styles in the level through a menu, which will change materials on some of the actors in the level.

I've got some ideas but I'm new to UE so I am not sure if there is an easier or better way to do this.

At the moment I've got my style changer widget which shows the menu and handles the logic of changing the styles. I was going to implement a global event system and have the widget broadcast the style that has been selected, and then have a blueprint component assigned to the actors that I want to change materials for. This blueprint will listen for the event and switch the materials.

Two questions - firstly, does this sound like a good way to handle this?

Secondly, none of this data needs to be set at runtime or dynamically; the styles and the materials to switch between are all pre-defined. What is the best way to handle this in the editor? I have created a custom struct which is used by my style changer widget which is an array that contains the name and a few other pieces of information of each style. I then wanted to have each blueprint component on the actors read that array and, in the editor, pre-populate it's own array with the styles from the widget so that I can then assign materials. I can access the widget's styles variable at runtime, however, I can't find out how to run a blueprint in the editor such that the array will get pre-populated with the styles. Is this possible?

I'm currently using blueprints for this, but I can use C++ if it will work better.

Product Version: UE 4.14
more ▼

asked Feb 22 '17 at 11:22 PM in Blueprint Scripting

avatar image

8 2 5

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

First, yes, I think that's a great use for global events - since you don't have a pre-populated list of actors to call.

I don't quite understand your second question, but the way I would do it is take a global object like the gamemode, add in a variable of your struct, click the array grid. Then, in the default for that array, add in the data. If you only have the name (and can't create a reference directly to the material), then you have to do more fixup, but the gamemode or gameinstance is probably a reasonable place to do that as well. If you send a picture I can probably give you more targetted data.

The actors can GetGameMode() -> Cast to your game mode() -> access the array.

Structure (MyMaterialStruct) Material Array Variable on Game Mode Accessing the material array from any blueprint

graph4.png (23.3 kB)
graph5.png (40.9 kB)
graph6.png (42.7 kB)
more ▼

answered Feb 23 '17 at 05:52 AM

avatar image

396 11 8 25

avatar image matter3d Feb 23 '17 at 11:05 PM

Awesome, thank you for the information! :)

(comments are locked)
10|2000 characters needed characters left
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