UIS integration issue

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
christianwiele
Posts: 29
Joined: Sat Mar 27, 2021 7:34 am

UIS integration issue

Post by christianwiele »

Hi,

I am using the DS with the Opsive UCC/UIS in a multiplayer setting. After the lastest update of the multiplayer add-on I run into an issue when using the UIS Lua functions. Before the update the local player was always spawned first. So the GetInventory method of the UISLua class found the local player first (by using the "Player" tag). Now the master player is spawned first also on the client, and the local player is spawned later. Thus the GetInventory will return the inventory of the master player game object, not the one of the local player. Both players can have a conversation with NPCs, so I cannot hard code the inventory/player names. Is there a way to retrieve the GO name of the current player / conversant. Then I could pass this name as second argument to the Lua functions?

Thanks, Christian
User avatar
Tony Li
Posts: 22158
Joined: Thu Jul 18, 2013 1:27 pm

Re: UIS integration issue

Post by Tony Li »

Hi,

If the GameObject name matches the player's actor name, then you can use the variable Variable["Actor"]:

Code: Select all

uccAddItem(Variable["Actor"], "Apples", 3)
One way to get the player's actor name to match the GameObject name is to add a Dialogue Actor component to the player GameObject and set its DialogueActor.actor field to the GameObject name. Example:

Code: Select all

GetComponent<DialogueActor>().actor = gameObject.name;
christianwiele
Posts: 29
Joined: Sat Mar 27, 2021 7:34 am

Re: UIS integration issue

Post by christianwiele »

Thanks for the quick response. Just one question. Is the Actor variable always the same during a conversation, or does it change from step to step (because Actor and Conversant constantly switch roles here)?
User avatar
Tony Li
Posts: 22158
Joined: Thu Jul 18, 2013 1:27 pm

Re: UIS integration issue

Post by Tony Li »

The Actor variable corresponds to the actor or GameObject that's being used as the conversation's primary actor -- that is, the GameObject assigned to the Dialogue System Trigger's Conversation Actor field or, if the field is unassigned, according to the rules here: Character GameObject Assignments.

If you're using the Opsive integration's DialogueSystemTriggerInteractable component, and if you've left the Conversation Actor field blank, it will use the player GameObject that triggered the interaction.
christianwiele
Posts: 29
Joined: Sat Mar 27, 2021 7:34 am

Re: UIS integration issue

Post by christianwiele »

Thanks again. The life of an indie dev can be tough sometimes. Every time I get a quick and qualified response like yours, I feel honored and taken seriously. Keep up the great work, and your attitude towards us indie devs.
User avatar
Tony Li
Posts: 22158
Joined: Thu Jul 18, 2013 1:27 pm

Re: UIS integration issue

Post by Tony Li »

Glad to help!
christianwiele
Posts: 29
Joined: Sat Mar 27, 2021 7:34 am

Re: UIS integration issue

Post by christianwiele »

Hi,

for the conversation this approach works fine now. But I run into an issue with the Dialogue System Trigger. I need to check the inventory in the conditions. The problem for UCC is that the collider is not on the player game object, but on a child. If I use the Variable["Actor"] in the condition, it will return the collider GO name, not the player. And thus the inventory is not found.

Thanks, Christian
User avatar
Tony Li
Posts: 22158
Joined: Thu Jul 18, 2013 1:27 pm

Re: UIS integration issue

Post by Tony Li »

Hi,

The uccAddItem() command should find the Inventory on the child GameObject. If the Inventory component isn't on the main GameObject, it uses GetComponentInChildren<Inventory>() to search its children.
christianwiele
Posts: 29
Joined: Sat Mar 27, 2021 7:34 am

Re: UIS integration issue

Post by christianwiele »

Hi,

it's the other way around. The collider that interacts with the Dialogue System Trigger is on a child, so the inventory is on a parent. But I now created my on variable containing the local player name. I set this locally on each client, so it has different values on each client. With this I can get the correct inventory.

Thanks again for your help.
User avatar
Tony Li
Posts: 22158
Joined: Thu Jul 18, 2013 1:27 pm

Re: UIS integration issue

Post by Tony Li »

Glad to help! (Well, you really solved this one yourself, so I'm just glad you got it working.)
Post Reply