Pass text from widget to BP

Hi. In my game, I have a character walk up to an NPC and his name appears. I have the character’s name made in a widget. I call it from the NPC. But if there are a lot of NPCs, I will have to create many separate widgets in text - character name. I made a variable from the text field, but I don’t know how to use it to pass in the NPC field so that I just write the name at any NPC. Please help.


Hey @Stop-TussiN!

I think what you need here is on BeginPlay, you’ll take that widget, cast to its widget type (name_provodnica), use “As name provodnika” to get your “name npc in world” text, then set it. Like so!

image
You will also want to ensure that all of your NPCs have the same parent. That way you can give all of these variables to the parent, and then through “Edit Defaults”, when you make a new character, just change a few values like name text and dialogue per-character. :slight_smile:

You could just have a Text Render component in the NPC above the head or where ever and on overlap it shows.

Error :frowning:

@Rev0verDrive my brain-wires crossed and for some reason this came out as the same thing.

@Stop-TussiN They’re right, the same effect can be achieved using a text render component instead of a widget component, since your widget is only text anyway. It’d be much easier to deal with plus a tiny bit less overhead.

As far as the cast goes, forgot this was a component. You should be able to simply drag off of widget and get name npc in world- but I recommend this less than simply using a text render component and setting that text individually per character.

:rofl: It happens to me as well.

I thought about this, but in this case the text will be displayed exactly on one side only. I need the text to always face me, no matter which side I approach the object from.

No problem!

You can have it rotate to face the player or player camera on tick!

Disclaimer: This link is not associated with Unreal Engine, Epic Games LLC, or their partners.

It doesn’t seem like it, the text is not translated into Russian. And I like my option, it has more text settings. Please tell me how to do it exactly in my version. Very necessary

I also need this because I will want to change the text design at some time, and I don’t want to go into every NPC and change the text design there. I want it to be in one place, and the names of the NPCs to be written directly in them

Sorry, I’m not quite understanding what you mean by “I want it to be in one place, and the names of the NPCs to be written directly in them”. Can you try to explain in more detail?

Also, feel free to additionally post in your native language if it isn’t English! :slight_smile:

Мне нужно вставить поле ввода имени в NPC, и чтобы через виджет я оформлял вывод этого текста в игре.
Сейчас же я для каждого NPC создаю отдельный виджет с его именем и вызываю его показ. В игре уже больше 20 NPC и создана 20 виджетов с выводом имени. А я хочу сделать всего один виджет на все NPC)
Вот изобразил на скриншотах )



Help me please

Solved the issue

1 Like

Hey @Stop-TussiN! Sorry for the late reply, but great to hear that you got it figured out! Would you possibly mind Explaining what you did here so if anyone else comes looking for a similar solution, they can find it? If you could do that, it would be fantastic!