Page 1 of 1
Player to Face NPC
Posted: Fri Sep 20, 2024 1:15 am
by c166
Hey Tony,
I want to make the player and NPC face each other when the conversation starts. I know about the Sequencer (LookAt(listener, speaker, 1); ), and I thought that by placing them in the default sequence/ player sequence that I'd be able to achieve this behavior.
- default_sequences.PNG (23.96 KiB) Viewed 104 times
This worked in the Dialogue Demo Scene, but when I play it in my own scene. Only the NPC rotates to face the player. I am not sure if there is something obvious I am missing? (e.g. a component that needed to be assigned?)
Best Regards,
C
Re: Player to Face NPC
Posted: Fri Sep 20, 2024 8:14 am
by Tony Li
Hi,
Make sure player and NPC GameObjects are being used as the speaker and listener. Please see
Character GameObject Assignments.
I recommend moving the LookAt() command to the first dialogue entry node in the conversation. This way you won't get unexpected side effects if you involve an additional character in a later node in some conversation.
If you want to have both characters change their rotations immediately to face each other, rather than rotating gradually over 1 second, you can use "LookAt()" without any parameters.
Re: Player to Face NPC
Posted: Fri Sep 20, 2024 10:02 pm
by c166
Hey Tony,
Thanks for that, I checked and those have been set up correctly - but thanks to ruling out me missing something basic on the Dialogue system side, I realized that the reason is because my player character is using a kinematic controller which can't have the rotation directly modified.
I ended up creating a custom look at sequencer - which is exactly the same as the PixelCrusher LookAt, except with a call to a function if the subject is the player to provide those update references via the KinematicController. Now everything works as expected (both characters turn to look at one another on conversation start)
Code: Select all
// If the subject to rotate is the player
if(subject.GetComponent<PlayerController>()!=null)
{
Debug.Log("Custom Look At To trigger player look at object");
subject.GetComponent<PlayerController>().PlayerLookAtObject(target.gameObject);
}
So now I'll be able to trigger the mutual LookAt using the via the dialogue notes/ sequencer workflow - which makes it much easier to handle. I was setting calls to those functions in "OnConversationStart" via the Dialogue System Trigger previously (before I found out about the Sequencer functionality); which was hard to keep track of.
Best Regards,
C
Re: Player to Face NPC
Posted: Fri Sep 20, 2024 11:41 pm
by Tony Li
Hi,
BTW, another alternative would be to disable the PlayerController script (or whatever script is holding onto the player's rotation) during conversations. A Dialogue System Events component is often used to do this, as shown in the
Interaction Tutorial video.