NPC Look at Player

Announcements, support questions, and discussion for the Dialogue System.
User avatar
Tony Li
Posts: 20397
Joined: Thu Jul 18, 2013 1:27 pm

Re: NPC Look at Player

Post by Tony Li »

I sent Opsive a new version of the Dialogue System integration this week, too, so please also download and import that. There's also a new version of the Dialogue System (2.1.7) that released this week.

If that doesn't help, please feel free to send me a reproduction scene / project.
nitrox32
Posts: 68
Joined: Sat Dec 01, 2018 10:41 am

Re: NPC Look at Player

Post by nitrox32 »

I've started a fresh project and loaded in UCC 2.1.4(current) and DS 2.1.7. I have also added the "DS2_UCCSaver_2018-12-12.unitypackage" to the project. Nothing else exists in the project. I am now getting these errors:

Assets\Pixel Crushers\Common\Third Party Support\Opsive UCC Support\Scripts\UCCSaver.cs(186,42): error CS0103: The name 'UCCUtility' does not exist in the current context

Assets\Pixel Crushers\Common\Third Party Support\Opsive UCC Support\Scripts\UCCSaver.cs(196,40): error CS0103: The name 'UCCUtility' does not exist in the current context

I think I have an older version of the integrations package. This could be the root of the problem. Do you have a current one?
User avatar
Tony Li
Posts: 20397
Joined: Thu Jul 18, 2013 1:27 pm

Re: NPC Look at Player

Post by Tony Li »

I maintain the integration, but Opsive hosts it. Select Tools > (Your Opsive Controller) > Integrations Manager.

This will open Opsive's integrations window. Next to the Dialogue System icon, click Integration. This will open Opsive's website, where you can download the latest version of the integration.
nitrox32
Posts: 68
Joined: Sat Dec 01, 2018 10:41 am

Re: NPC Look at Player

Post by nitrox32 »

Will do. BTW is what I have the latest?
User avatar
Tony Li
Posts: 20397
Joined: Thu Jul 18, 2013 1:27 pm

Re: NPC Look at Player

Post by Tony Li »

Hi,

The latest is on Opsive's website. I also just PM'ed you direct links.

The UCCLua file on the Extras page is older.
User avatar
Tony Li
Posts: 20397
Joined: Thu Jul 18, 2013 1:27 pm

Re: NPC Look at Player

Post by Tony Li »

For future readers, we resolved this through email by making these changes:
  • On the NPC, assigned the Dialogue System Trigger > Start Conversation > Conversation Actor = Player, Conversation Conversant = NPC.
  • Added a Dialogue System Events component to the NPC that disables the NavMeshAgent and UltimateCharacterLocomotion during conversations. This allows the LookAt() command to rotate the NPC without these components overriding the rotation.
  • Changed the Sequence to:

    Code: Select all

    LookAt(listener); Camera(Closeup,speaker,1)
  • Then, for a slight visual improvement, changed the Sequence to:

    Code: Select all

    LookAt(listener,,0.5); LiveCamera(Closeup,speaker,1)
    The LookAt command rotates over time instead of snapping into position. The LiveCamera command is like Camera except it follows the subject as it moves/rotates.
nitrox32
Posts: 68
Joined: Sat Dec 01, 2018 10:41 am

Re: NPC Look at Player

Post by nitrox32 »

Thanks for fixing and sending me the corrected scene. Everything works as expected so decided to go the next step and add Behavior Designer so that the NPC will wander then respond when approached to start a conversation. When I approach the wandering NPC the conversation starts properly and the camera looks at the player as expected however I get the following repeating error when the conversation begins:

"GetRemainingDistance" can only be called on an active agent that has been placed on a NavMesh.
UnityEngine.AI.NavMeshAgent:get_remainingDistance()
BehaviorDesigner.Runtime.Tasks.Movement.NavMeshMovement:HasArrived() (at Assets/Behavior Designer Movement/Scripts/Tasks/NavMeshMovement.cs:104)
BehaviorDesigner.Runtime.Tasks.Movement.Wander:OnUpdate() (at Assets/Behavior Designer Movement/Scripts/Tasks/Wander.cs:30)
BehaviorDesigner.Runtime.BehaviorManager:RunTask(BehaviorTree, Int32, Int32, TaskStatus)
BehaviorDesigner.Runtime.BehaviorManager:Tick(BehaviorTree)
BehaviorDesigner.Runtime.BehaviorManager:Tick()
BehaviorDesigner.Runtime.BehaviorManager:Update()


I am not sure if this is a DS or a UCC problem. Should I be using DS behavior tasks within a Behavior Tree instead of the approached currently used or is there an easier fix?
User avatar
Tony Li
Posts: 20397
Joined: Thu Jul 18, 2013 1:27 pm

Re: NPC Look at Player

Post by Tony Li »

Hi,

There are two directions you can take to get it working:

1. From the Behavior Designer side: In your behavior tree, add a branch that checks "Is Conversation Active". If this is true, stop trying to navigate around.

or

2. From the Dialogue System side: In the NPC's Dialogue System Events component, configure OnConversationStart() to call the Behavior's DisableBehavior:true, and configure OnConversationEnd() to call EnableBehavior.


The advantage of #1 is that it allows the behavior tree to keep running during the conversation. The advantage of #2 is that you don't have to fiddle with another branch (Is Conversation Active) in your behavior tree.
nitrox32
Posts: 68
Joined: Sat Dec 01, 2018 10:41 am

Re: NPC Look at Player

Post by nitrox32 »

Looks like solution #2 worked out the best. Thanks!
User avatar
Tony Li
Posts: 20397
Joined: Thu Jul 18, 2013 1:27 pm

Re: NPC Look at Player

Post by Tony Li »

Glad to help!
Post Reply