Convert enum/string to object(material) name?

Hello,

I am in the process of setting up a change in the material of an actor when my game gets to a certain area. This area is defined by a structure, and when it brings it in from the datatable.

The issue that I am having so far is how I should get where it needs to be.

So far, I have thought of two solutions

  1. Add the background column to an enum list in my structure, convert that into a string, pass it into a material variable.

Issue with this: I have searched far and wide and there seems to be no actual way to parse a string into a material name

  1. Set the enum list instead to a material itself

Issue with this: The material never ![alt text][1]seems to change, each time a new one is called, it stays at its default as if it cannot understand the data it is getting from the datatable to be the name of the called material.

Ive been eating away at this slowly, but I am sort of running out of ideas. The only thing I could think of is dynamically setting the name via the material itself and a public variable from my game mode, but that probably isnt what would be advised.

Is anyone aware of what I could do with this?

I will check this out. I hate to ask, but do you have an example? Or can I use the enum list to int each material? Since I did bring in the standard starter pack to test things out and whatnot.

On one level in my game, I have these kind of remote beacons. They broadcast a sound, and you can see a shape coming from the beacon. As the level gets more complex, there’s also colors, and other shapes that you need to use a telescope to see.

Locally, to be able to use the teleporter, the player has to enter the combination of materials, sounds, positions etc correctly.

When I first did this it was total nightmare, because I was comparing references to materials, sounds, shapes etc.

Later I realized that all I had to do was put the materials ( for instance ) in a fix order in both the beacon and the teleporter control panel. Then all I had to do was check if the array index was the same.

The same thing goes for all the other attributes. All I have to do is compare integers, because I know that I put the attributes into the array in the correct order.

I don’t understand what you have going on there. But if you have materials assocated with areas, why not number the areas 0 - N, and put the materials in an array so that the material that goes with area 0 is first in the array, the material that goes with area 1 is the next thing in the array etc.

That way, when you arrive at an area, all you have to do is access the material array using the area number, and boom, you’ve got the right material.

I know that’s a very simplistic example, but I hope you see what I mean…

My blueprint is looking jank as heck, but this absolutely worked. With a little cleaning up on my end it will look exactly like I expected.

Turn one of your replies into an answer and i’ll give you a big old thumbs up!

When I first started using UE I was doing this kind of thing. To check the solutions to puzzles for instance, I was comparing material names and had all kinds of enums a instance references going into switch nodes yada yada yada.

Then what I discovered one day is it’s MUCH easier to just use integers :slight_smile:

Just put everything in your data table / array / whatever in a known order. When you want to use a row or compare things just use the array index or row ID or whatever.

EDIT: I know it might sound like a bit of a leap. Maybe explain your material/area concept a little and I’ll give you the IntegerMind point of view…

Excellent :slight_smile:

BTW: Hint if you ever want to order the items randomly. Still put them in the array in the correct order, but then just have a second array to contain the shuffled indexes.