Can I change chat text colour based on whos talking?

I have a chat input box which takes text and a players name from the player controller and sends it out to all other players chat boxes in game. I also have a variable material instance in each player that randomizes on game start. So someone will be red, blue, green etc.

I’d like the Player’s name component of the chat message to be coloured the same as that material so other players can be aware of which colour player is talking.

Is there any way to do this?

I’ve figured out how to change the chat colour but it takes a Slate Colour which only takes a linear colour input, not a material object. My material has a parameter called base color. Any idea how I can convert that into a slate colour?

I figured out how to do it, basically I had to get the player controlled pawn, cast to the character class which contains the array of materials, use the index each player controller is assigned at spawn to match the material chosen from the list, then create a dynamic material from that colour. Then I use Get Vector Parameter value to get the Base Color Parameter on that material, which can be passed to the Make Slate Color function.

Then I convert it to a slate colour and pass that through as an input to my Server chat function, I could then pass the slate colour which is needed as an input to the Set Opacity to text block function, I pass that through when I create the message and it matches the player colour who sent it.

I would share the blueprint but its a bit of a mess lol

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.