How can I show player's name during the lines?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
muramasa
Posts: 20
Joined: Tue Feb 11, 2020 7:29 am

How can I show player's name during the lines?

Post by muramasa »

Hey guys!

Could anyone tells me how can I show Player or Actor's name during the lines, please?
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: How can I show player's name during the lines?

Post by Tony Li »

Hi! There are a few ways:

1. Use a Dialogue UI whose subtitle panels have Portrait Name fields. Example: In the Demo, when you talk to the NPCs, their name appears in the subtitle panel along with their dialogue text.

2. Or inspect the subtitle panel(s) and tick the Add Speaker Name checkbox. This will prepend the speaker's name to the front of the dialogue text.

3. Or, if you want to show the player's name in the dialogue text itself, use the [var=variable] tag, such as:
  • Dialogue Text: "Hello, [var=Actor]. How are you?"
If the player actor is not assigned as the conversation's Actor for any reason, you can use [lua(code)]. If you need to do this, let me know. It depends on how you've set up your actors. For example, if your actor is named "Player" and Use Display Name is ticked, you'd do this:
  • Dialogue Text: "Hello, [lua(Actor["Player"].Display_Name)]. How are you?"
Note: If you don't see the player's lines at all, make sure you've ticked the Dialogue Manager's Subtitle Settings > Show PC Subtitles During Line.
User avatar
muramasa
Posts: 20
Joined: Tue Feb 11, 2020 7:29 am

Re: How can I show player's name during the lines?

Post by muramasa »

Awww! thanks for your help! point 3 is exactly what I need.

your system is the best dialog system of Unity! :)
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: How can I show player's name during the lines?

Post by Tony Li »

Thanks! Glad to help!
Post Reply