NPC Face player

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
hrohibil
Posts: 380
Joined: Thu Nov 04, 2021 12:50 pm

NPC Face player

Post by hrohibil »

Hi Tony

I have a Dialogue System trigger on my NPC.
How do I make so if my player comes from behind that the NPC faces the player direction?

Also I am using a camera which is close up. Will I need to move this as well?
User avatar
Tony Li
Posts: 22655
Joined: Thu Jul 18, 2013 1:27 pm

Re: NPC Face player

Post by Tony Li »

Hi,

For a 3D game, use the LookAt() sequencer command. This rotates the subject to face the target. If you don't provide any parameters, it rotates the actor and conversant to face each other.

For a 2D game, you'll have to write your own sequencer command or handle it in a Dialogue System Events component set to OnConversationStart or use an OnConversationStart(Transform) method on the NPC. This is because 2D facing is different based on whether it's a side scroller or top down, and whether you're rotating along an axis to flip the character or setting the sprite renderer's Flip X.
hrohibil
Posts: 380
Joined: Thu Nov 04, 2021 12:50 pm

Re: NPC Face player

Post by hrohibil »

Worked perfectly 👍
Thank you
User avatar
Tony Li
Posts: 22655
Joined: Thu Jul 18, 2013 1:27 pm

Re: NPC Face player

Post by Tony Li »

Glad to help!
Post Reply