I am trying to change the materials of an object based on its current material. I got it all setup and the basics work, the problem now is that I am using the Name of the material to search for the index of the material to then apply a new Material too, This works Perfectly well the first time. However when I try to do the same thing again ( in run time) It now says the material is assigned to index -1.
Do Materials added in run time always get assigned the index -1? Or is there a way to make sure that the new material has the same index as the old material.
Maybe you could try assigning the materials an integer index variable manually and use and increment ++ and just do branch checks instead of relying on what they may be assigned? When you get to the end of your desired materials you can set your variable back to whichever index you want…
I think my qeustion might not have been clear enhough. The problem isn’t that the Material Index variable gets set to something I don’t want. Its that the material that gets placed on the object after the first running of the script. is set to index -1. so its not the index itself. but the index of that specific material
and here is the 2nd time. as you can see the first time it hits the object it correctly displays the index 1 which then calls the widget and sets the material index to 1 to target that material.The second hit says the index of that material is -1. Which is not a valid index asfar as i understand. And I am not sure if there is even any bandaid I could use to retarget the right index. I think my whole idea might be somewhat flawed eitherway because if 2 materials would be the same on the object I think the script would break anyway.
Sorry for the late reply. I see your interface event has a material index pin. What kind of logic are you using for that pin? If its getting the index from that pin have you tried switching on int straight off that pin? Maybe try making your variables instance editable.
It may be that you are setting an integer variable for the index, but not necessarily on the material itself? So you might not be getting the index you set, but what it’s finding on your trace…
Sorry if Im not understanding your issue completely…
The material index from the interface is actually the face index, I misunderstood it at first and forgot to change its name, the Real index comes from the materialName and the searching for that index.
I have tried a lot of different things by now, and sadly non of them seem to work. Think I am just gonna look for another solution, Either Just split up walls into sepperate blueprints, ur using a widget to select the proper target.
I am sure that something like this should be possible but can’t quite figure out the trick