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"

Change parameters of mesh with multiple materials

Greetings, i'm currently working on a Top/Down Adventure game and i've stumbled upon a problem I'm not exactly sure how to fix. So basically I have a blueprint that makes a mesh turn transparent if it gets into collision with the player camera. This system works fine but the problem is that it only works if the mesh has one material. I kinda understand where the problem is I just don't really know how to implement a solution. I believe that the solution lies with how the dynamic material is created in Event BeginPlay. When I GetMaterial from the Static Mesh the element Index is set to 0 so I imagine thats why it only affects the first material and not the rest. Im not sure how I would go about making it create a dynamic material for each material within the static mesh. Arrays are probably the solution? Any ideas?

Thanks.

alt text alt text alt text

Product Version: UE 4.19
Tags:
hide-material.png (169.8 kB)
hide-material2.png (177.1 kB)
hide-material3.png (118.8 kB)
more ▼

asked Mar 30 '19 at 09:06 PM in Using UE4

avatar image

OniricMaster
26 2 4 9

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

1 answer: sort voted first

if you have multiple materials then you should just need a loop which repeats the process for each material. on begin play you will get the number of materials then run a for loop for each material. the get num materials node should output a number greater than zero and the material indexes are zero based so you will likely need to subtract one from the num materials. after that is basically the same procedure you were doing. the exception comes at the end where your storing the materials in a variable, here you will want to add them to an array via the add node. the other change comes in your update vis function here you will again need to loop to go through each material instance. so you get your array and use a for each loop which will run the script following it for every material stored in the array.

alt text

capture.png (262.1 kB)
more ▼

answered Mar 30 '19 at 10:25 PM

avatar image

ThompsonN13
10.4k 34 10 27

avatar image OniricMaster Mar 31 '19 at 10:24 AM

I've added what you suggested but i'm having the same result i'm not sure why. It still only makes the first material disappear.

alt text

alt text

material-0.png (120.2 kB)
material-1.png (221.6 kB)
avatar image OniricMaster Mar 31 '19 at 10:36 AM

Ok Ive figured it out, basically it does actually work but not with the system ive got. If I connect the Completed node from the ForEachLoop to the Return Node it does affect all the materials but it wont go back to its initial opacity once the mesh is not in contact with the player camera. Ill just modify my system a bit so it works properly. Thanks a lot for the help.

(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