Making the UI follow the NPC
Making the UI follow the NPC
Hi, so I have almost everything working except for the UI. I'm using EmeraldAI and a world space camera for VR, when the NPC starts moving the dialogue box stays where I placed it (originally infront of the NPC), I was wondering how i'd get it to follow the NPC so when it's activated it's infront of the NPC no matter where the NPC has wandered. I tried placing it inside the NPC so that it was it's parent but then it just stopped appearing all together
Re: Making the UI follow the NPC
Hi,
A world space canvas childed to the NPC is the way to go. If it's not visible, pause the game and check where it is. Maybe it needs to be higher or lower, or maybe the NPC's scale is causing the canvas to be scaled too small or too large.
A world space canvas childed to the NPC is the way to go. If it's not visible, pause the game and check where it is. Maybe it needs to be higher or lower, or maybe the NPC's scale is causing the canvas to be scaled too small or too large.
Re: Making the UI follow the NPC
--
Last edited by Smugz on Tue Jan 05, 2021 10:53 am, edited 1 time in total.
Re: Making the UI follow the NPC
Hi, so I got this working and it's lead me onto what is hopefully my final question. Using Emerald AI, is there a simple option in dialogue manager to make the NPC stop moving and face the player?
Re: Making the UI follow the NPC
Hi,
Set the Emerald AI's Temperament > Behavior to Passive and Wander Type to Stationary.
One way is to add a script that has OnConversationStart and OnConversationEnd methods to the AI. (See Script Methods.) In OnConversationStart, use the Emerald AI API to set Behavior and Wander Type. In OnConversationEnd, set them back to their original values.
Another way to do it without scripting is to add two extra Dialogue System Triggers:
This uses the LookAt sequencer command to make the speaker (the NPC) look at the listener (the player).
Set the Emerald AI's Temperament > Behavior to Passive and Wander Type to Stationary.
One way is to add a script that has OnConversationStart and OnConversationEnd methods to the AI. (See Script Methods.) In OnConversationStart, use the Emerald AI API to set Behavior and Wander Type. In OnConversationEnd, set them back to their original values.
Another way to do it without scripting is to add two extra Dialogue System Triggers:
- Set one to OnConversationStart. Select Add Action > Run Lua Code. Use the integration's Lua Functions SetEmeraldBehavior and SetEmeraldWander. For example:where MyGameObject is the name of the AI.
Code: Select all
SetEmeraldBehavior("go=MyGameObject", "passive"); SetEmeraldWander("go=MyGameObject", "stationary")
- Set the Dialogue System Trigger to OnConversationEnd. Use Run Lua Code to set the behavior and wander state back to their original values.
Code: Select all
LookAt(listener,speaker); {{default}})
Re: Making the UI follow the NPC
So I noticed you said "something like", so i've been trying different variations I could think of, and read through the Sequencer help stuff but still had no success. The Character stops moving now which is great, just refuses to look at the player.In your conversation's first node (the one after <START>), set the Sequence field to something like:
CODE: SELECT ALL
LookAt(listener,speaker); {{default}})
This uses the LookAt sequencer command to make the speaker (the NPC) look at the listener (the player).
Re: Making the UI follow the NPC
I forgot that Emerald AI takes control of the GameObject's rotation. I don't remember the details of how it keeps control. You may need to dig into the code of EmeraldAISystem or ask on BHS's forum how to rotate an Emerald-controlled GameObject. Alternatively, you could try just temporarily disabling the EmeraldAISystem component during the conversation.
Re: Making the UI follow the NPC
I did a little checking. If the Emerald AI is set to Stationary, then you can rotate it.
Make sure the player is assigned to the Dialogue System Trigger's Actions > Start Conversation > Conversation Actor. Then set the first NPC node's Sequence to:
I changed up the command a little to make the speaker (NPC) rotate to the listener (player) gradually over a duration of 1 second. But the original command should work fine, too.
Make sure the player is assigned to the Dialogue System Trigger's Actions > Start Conversation > Conversation Actor. Then set the first NPC node's Sequence to:
Code: Select all
LookAt(listener,,1);
{{default}}
Re: Making the UI follow the NPC
Sorry for the long reply I got caught up in some other stuff, so the rotating thing worked when I set the character to stationary, however when I try to run the lua code to change from Dynamic wandering to Stationary I get this error, not entirely sure why. (I did also try capitalising the S)
SetEmeraldWander("go=Stark", "stationary")' threw exception 'Tried to invoke a function call on a non-function value. If you're calling a function, is it registered with Lua?'
SetEmeraldWander("go=Stark", "stationary")' threw exception 'Tried to invoke a function call on a non-function value. If you're calling a function, is it registered with Lua?'
Re: Making the UI follow the NPC
Hi,
Did you add an Emerald AI Lua component to your Dialogue Manager?
If so, check the spelling and capitalization of your Lua code.
Did you add an Emerald AI Lua component to your Dialogue Manager?
If so, check the spelling and capitalization of your Lua code.