Change Actor Field on Runtime using Variables

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
KakimaAkuma
Posts: 29
Joined: Mon Sep 09, 2019 9:51 pm

Change Actor Field on Runtime using Variables

Post by KakimaAkuma »

I've read the threads "change Actor's name on runtime" and "Set player display name in code"

Note: TL:DR down below

I got some few questions of my own.

https://gyazo.com/a5f13c3aa08e7934700435745163ed1a

I have an actor MainPlayer who has field of FirstName and LastName

https://gyazo.com/6a8ec0dd3d39e318f82d1741817c5c80

I used TextInput Sequence for player input.

The variable changed successfully. But I have an issue on changing Actor fields seen below.

https://gyazo.com/bb15ef0eb10be120074ac4992b9b0bcf

I've tried both
[*]Actor["MainPlayer"].FirstName = Variable["FirstName"]
and
[*]Actor["MainPlayer"].FirstName = [var=FirstName]

Nothing happened on the first script but the second script returned an exception "Failed to parse Letter of Name


TL:DR = I can't seem to find the correct syntax to assign variables to actor fields on runtime
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Change Actor Field on Runtime using Variables

Post by Tony Li »

Hi,

When the conversation plays a dialogue entry, it uses this order:
  • Checks the Conditions. If they are false, it does not play the entry.
  • Runs the Script.
  • Shows the Dialogue Text.
  • Runs the Sequence.
If you want to run Actor["MainPlayer"].FirstName = Variable["FirstName"] in a Script, it must be in a dialogue entry after the one that runs the TextInput() command.

I suspect this is the issue. If not, please let me know.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Change Actor Field on Runtime using Variables

Post by Tony Li »

Here's an example scene:

DS_FirstNameExample_2019-09-10.unitypackage

(Exported from Unity 2018.1)

The first dialogue entry runs TextInput().

The second dialogue entry runs the Script that assigns the variable to the actor field, and it also shows the value in the Dialogue Text.
Post Reply