Page 1 of 1
UIS integration issue
Posted: Thu Oct 14, 2021 2:42 pm
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
Re: UIS integration issue
Posted: Thu Oct 14, 2021 3:49 pm
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;
Re: UIS integration issue
Posted: Thu Oct 14, 2021 5:07 pm
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)?
Re: UIS integration issue
Posted: Thu Oct 14, 2021 8:12 pm
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.
Re: UIS integration issue
Posted: Fri Oct 15, 2021 2:08 am
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.
Re: UIS integration issue
Posted: Fri Oct 15, 2021 7:56 am
by Tony Li
Glad to help!
Re: UIS integration issue
Posted: Mon Oct 18, 2021 12:22 pm
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
Re: UIS integration issue
Posted: Mon Oct 18, 2021 1:13 pm
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.
Re: UIS integration issue
Posted: Mon Oct 18, 2021 1:45 pm
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.
Re: UIS integration issue
Posted: Mon Oct 18, 2021 1:51 pm
by Tony Li
Glad to help! (Well, you really solved this one yourself, so I'm just glad you got it working.)