NPC Look at Player
NPC Look at Player
I'm using DS and UCC together and I have managed to get my player and NPC to interact using OnTriggerEnter to start the conversation and pause the game while conversing. I would like the NPC to face me. This seems simple to do but I can't find any info on how to do it. Can you point me in the right direction?
Re: NPC Look at Player
OK, I figured out that I can do a sequence "Camera(Closeup, listener, 1)" that does what I want however the player is in the background of my NPC. This only happens when I approach the NPC from the back. The player is a UCC first person character.
Re: NPC Look at Player
Hi,
The Dialogue System has an Opsive UCC integration package. You can use UCC's Interact ability to start a conversation if you want, or continue to use OnTriggerEnter, or mix and match in different situations.
In addition to the Camera() sequencer command, you can also use the LookAt() sequencer command to rotate GameObjects (such as the NPC) to face other GameObjects. For example, the sequence below will rotate the NPC to face the player and then move the camera into a closeup of the NPC. It assumes that it's on a dialogue entry node that's spoken by the NPC (i.e., a gray node).
The first line tells the speaker (the NPC) to face the listener (player). The second line does a closeup of the speaker (NPC) over 1 second.
If you're editing the Sequence field for a player node (i.e., blue), it would be:
The first line tells the listener (NPC) to face the speaker (player). The second line does a closeup of the listener (NPC).
The Dialogue System has an Opsive UCC integration package. You can use UCC's Interact ability to start a conversation if you want, or continue to use OnTriggerEnter, or mix and match in different situations.
In addition to the Camera() sequencer command, you can also use the LookAt() sequencer command to rotate GameObjects (such as the NPC) to face other GameObjects. For example, the sequence below will rotate the NPC to face the player and then move the camera into a closeup of the NPC. It assumes that it's on a dialogue entry node that's spoken by the NPC (i.e., a gray node).
Code: Select all
LookAt(listener);
Camera(Closeup, speaker, 1)
If you're editing the Sequence field for a player node (i.e., blue), it would be:
Code: Select all
LookAt(speaker,listener);
Camera(Closeup,listener,1)
Re: NPC Look at Player
Thanks for getting back to me so quickly. Perhaps I am entering something incorrectly but I still have my player shown in the background.
Re: NPC Look at Player
Try changing that node's Sequence to:
This will make the Archer face the player. Your current sequence makes the player face the Archer.
If the Archer is facing the player before the closeup, then the player will not be in the background.
Code: Select all
LookAt(listener); Camera(Closeup,speaker,1)
If the Archer is facing the player before the closeup, then the player will not be in the background.
Re: NPC Look at Player
Hmmm.....I copied and pasted your sequence. I no longer have my player in view but the NPC doesn't fully look at the player. The camera closes in on the NPC but the NPC doesn't rotate to face the player.
- Attachments
-
- Capture2.JPG (92.85 KiB) Viewed 3091 times
Re: NPC Look at Player
Hi,
Would it be possible for you to send an example scene and dialogue database to tony (at) pixelcrushers.com? You can export them as a unitypackage and attach them to an email.
I'm not sure how to reproduce the issue. As a test, I took the Opsive UCC Support's "Opsive UCC Dialogue Example" scene and changed the Sequence of the first node of the Private Hart conversation ("We need to intercept the...") to:
When I played the scene and interacted with Private Hart, he turned to face the player, and then it did a closeup.
You could also try this:
This will make your NPC look at the camera instead of the player GameObject, in case they're not lined up for some reason.
Would it be possible for you to send an example scene and dialogue database to tony (at) pixelcrushers.com? You can export them as a unitypackage and attach them to an email.
I'm not sure how to reproduce the issue. As a test, I took the Opsive UCC Support's "Opsive UCC Dialogue Example" scene and changed the Sequence of the first node of the Private Hart conversation ("We need to intercept the...") to:
Code: Select all
LookAt(listener); Camera(Closeup,speaker,1)
You could also try this:
Code: Select all
LookAt(MainCamera); Camera(Closeup,speaker,1)
Re: NPC Look at Player
I just tried the new Sequence you suggested: LookAt(MainCamera); Camera(Closeup,speaker,1). I still notice the same behavior except I am getting this warning:
Dialogue System: Sequencer: LookAt() command: target is null.
UnityEngine.Debug:LogWarning(Object)
PixelCrushers.DialogueSystem.Sequencer:TryHandleLookAtInternally(String, String[]) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Sequencer.cs:1518)
PixelCrushers.DialogueSystem.Sequencer:HandleCommandInternally(String, String[], Single&) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Sequencer.cs:927)
PixelCrushers.DialogueSystem.Sequencer:ActivateCommand(String, String, Transform, Transform, String[]) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Sequencer.cs:674)
PixelCrushers.DialogueSystem.Sequencer:PlayCommand(QueuedSequencerCommand, String, Boolean, Single, String, String, String[]) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Sequencer.cs:644)
PixelCrushers.DialogueSystem.Sequencer:PlayCommand(QueuedSequencerCommand) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Sequencer.cs:613)
PixelCrushers.DialogueSystem.Sequencer:PlaySequence(String) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Sequencer.cs:547)
PixelCrushers.DialogueSystem.Sequencer:PlaySequence(String, Boolean, Boolean) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Sequencer.cs:557)
PixelCrushers.DialogueSystem.ConversationView:StartSubtitle(Subtitle, Boolean, Boolean) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/View/View/ConversationView.cs:160)
PixelCrushers.DialogueSystem.ConversationController:GotoState(ConversationState) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Controller/ConversationController.cs:168)
PixelCrushers.DialogueSystem.ConversationController:OnFinishedSubtitle(Object, EventArgs) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Controller/ConversationController.cs:224)
PixelCrushers.DialogueSystem.ConversationView:FinishSubtitle() (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/View/View/ConversationView.cs:383)
PixelCrushers.DialogueSystem.ConversationView:OnFinishedSubtitle() (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/View/View/ConversationView.cs:390)
PixelCrushers.DialogueSystem.Sequencer:FinishSequence() (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Sequencer.cs:475)
PixelCrushers.DialogueSystem.Sequencer:Update() (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Sequencer.cs:468)
Dialogue System: Sequencer: LookAt() command: target is null.
UnityEngine.Debug:LogWarning(Object)
PixelCrushers.DialogueSystem.Sequencer:TryHandleLookAtInternally(String, String[]) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Sequencer.cs:1518)
PixelCrushers.DialogueSystem.Sequencer:HandleCommandInternally(String, String[], Single&) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Sequencer.cs:927)
PixelCrushers.DialogueSystem.Sequencer:ActivateCommand(String, String, Transform, Transform, String[]) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Sequencer.cs:674)
PixelCrushers.DialogueSystem.Sequencer:PlayCommand(QueuedSequencerCommand, String, Boolean, Single, String, String, String[]) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Sequencer.cs:644)
PixelCrushers.DialogueSystem.Sequencer:PlayCommand(QueuedSequencerCommand) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Sequencer.cs:613)
PixelCrushers.DialogueSystem.Sequencer:PlaySequence(String) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Sequencer.cs:547)
PixelCrushers.DialogueSystem.Sequencer:PlaySequence(String, Boolean, Boolean) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Sequencer.cs:557)
PixelCrushers.DialogueSystem.ConversationView:StartSubtitle(Subtitle, Boolean, Boolean) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/View/View/ConversationView.cs:160)
PixelCrushers.DialogueSystem.ConversationController:GotoState(ConversationState) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Controller/ConversationController.cs:168)
PixelCrushers.DialogueSystem.ConversationController:OnFinishedSubtitle(Object, EventArgs) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Controller/ConversationController.cs:224)
PixelCrushers.DialogueSystem.ConversationView:FinishSubtitle() (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/View/View/ConversationView.cs:383)
PixelCrushers.DialogueSystem.ConversationView:OnFinishedSubtitle() (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/View/View/ConversationView.cs:390)
PixelCrushers.DialogueSystem.Sequencer:FinishSequence() (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Sequencer.cs:475)
PixelCrushers.DialogueSystem.Sequencer:Update() (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Sequencer.cs:468)
Last edited by nitrox32 on Tue Jun 11, 2019 9:54 pm, edited 1 time in total.
Re: NPC Look at Player
In the sequence, change "MainCamera" to the name of your camera GameObject.
Re: NPC Look at Player
Opps, I see what you mean. That took care of the warning. Now the Camera is closing in on the NPC but not rotating towards the player. I just realized I was using not using the most recent version of UCC. I was one version behind. I'm going to start over with a fresh project and see if that helps.