In the game I’m making, I want my players to be able to assign different colors to different objects, with each type of object having a different input. For example, I want one color for the Player, another for NPCs, another for buildings, another for enemies, etc. This would be done through a menu, and everything in each of those categories would have that color. My question is, where would I store that color information so that everything in the game can access it? And I do mean EVERYTHING. Blueprints, Materials, UI elements, you name it I want to be able to access it from the same place so that if it changes, everything changes with it. Is this possible and if so, how would I go about doing it?
So, in your color picker. Go ahead and click on drop down menu at the top (maked bellow)
When you click on it, you will have option to add themes. When you add theme, then you can drag and drop colors from SRGB Preview box (Old and new). When you drag it, it will be permanently added to that theme. You can drag multiple colors to remember them. Also you can remove them by dragging them to the trash can icon on the right.
Anywhere in the app, again click on dropdown and select your theme. When you select it, just click on the color and it will be applied.
Correct me if I’m wrong, but I don’t see a way to access theme colors from a Material or Blueprint Event Graph. I would need to access these colors in code, not just in the editor.
This is close to what I’m looking for, but I’m not seeing a way to access the color variables in a Material Graph. Or am I missing something?
You can set the color of the material using Material Instance.
Is there a way to access it in a Material Layer? That’s what I’m currently using to make the materials. And if I have to use the Material Instance, how exactly do I access this color on the Game instance? I’m a bit lost.
Oh, you trying to access a variable inside material? I don’t think you can do that.
What you can do - is change materials from BP using Material Instance.
I don’t know how is your project built, so I can’t give you the perfect solution. To figure that out is on you. All I can do, is point in a direction.
Yes, you are right. This is for UMG
Alright, after you guys’ help and doing some fiddling around, I ended up with this:
I have this setup in my game instance (make sure that the color variables are LINEAR color, not just color):
And this setup in my Player BP (connected to Event BeginPlay):
And then I have the parameter “PlayerColor” on a material that is the parent to all of the relevant materials. I should note that I added an extra material slot on the character mesh for the parent material. It doesn’t connect to anything on the mesh, it’s just there so the BP can access it.
I should note that I did NOT make a dynamic material in this case because I found this in the forums: Issue with Material Instances (both Constant and Dynamic)
It seems like you don’t need to make a Dynamic Material Instance because UE does it for you anyway? That’s what I got from this post at least. In the end though, this works like a charm! Thanks for the help guys.
Good to hear.
Make sure to mark thread as solved.
And hey, I didn’t know about set parameter, thanks. I used only dynamic. Now my life is going to be a bit easier.
I am the author of that post about the usage of MIDs and I would sincerely advise you to create your own MID and do it properly, as if you rely on UE to do it for you, you will have extreme performance hits, as you cannot keep track of the created MID reference, therefore you create one each time you set the parameters. Also, if you have multiple materials with that parameter name, one “set” will set them all, so again, please avoid this shortcut, as it’s a recipe for bad coding practices.
You could also use a material parameter collection and set the values therein in your server logic. Since the material on each client would (ideally) be the same, they’d all be pointing to the ‘same’ set of information, as driven by the server.
Thanks for the info! Good to see you’re still around lol. I guess I’ll have to do it the hard way then.
Not sure this applies to me as I’m making a single player game but thanks for the insight.
Most definitely it applies, no matter if it’s single or multiplayer. This relates to the way in which MIDs are created, so you have to make sure you create them explicitly, by yourself, and not get tricked by UE creating them implicitly behind the scenes, as then you will lose their references, not being able to control them later on, thus obliging you to always create new MIDs behind the scenes, for every time you update a parameter via the Set Scalar/Vector Parameter on Material node.
Oh I was completely agreeing with you, I was talking about the client/server stuff that IlIFreneticIlI was taking about. Sorry I’m being so late to these replies, Epic Forums isn’t sending me notifications.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.