Adding turn speed to LookAt disrupts the camera angle

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
HeraldDeus
Posts: 2
Joined: Mon May 29, 2023 7:00 am

Adding turn speed to LookAt disrupts the camera angle

Post by HeraldDeus »

I am trying to make an NPC turn to the player when is entering a dialogue. The code below works fine when I dont add speed to LookAt. However, once I add movement speed to LookAt, the camera moves to front of the NPC while the NPC turns around to the player.

My guess is that Camera changes the angle BEFORE the NPC turns so it doesn't know that its direction changed. Is there a quick way to fix this? Thank you


Adding this to Sequencer in Conversation

Code: Select all

Camera(Medium, speaker, 1);
LookAt(listener,,0.5);
User avatar
Tony Li
Posts: 21681
Joined: Thu Jul 18, 2013 1:27 pm

Re: Adding turn speed to LookAt disrupts the camera angle

Post by Tony Li »

Hi,

Is the camera connected to the player somehow? If not, then they're probably separate issues. The Camera() command moves the camera GameObject. The LookAt() command rotates the NPC GameObject.

Here are a couple of variations you could try:

Rotate listener first, then move camera to Medium angle on speaker:

Code: Select all

LookAt(listener,,0.5)->Message(DoneRotating);
Camera(Medium, speaker, 1)@Message(DoneRotating)
Keep recomputing the camera angle over the 1-second period:

Code: Select all

LiveCamera(Medium, speaker, 1);
LookAt(listener,,0.5);
HeraldDeus
Posts: 2
Joined: Mon May 29, 2023 7:00 am

Re: Adding turn speed to LookAt disrupts the camera angle

Post by HeraldDeus »

Yes the camera is a child of the player. Your code seemed to do the job, thank you!
User avatar
Tony Li
Posts: 21681
Joined: Thu Jul 18, 2013 1:27 pm

Re: Adding turn speed to LookAt disrupts the camera angle

Post by Tony Li »

Glad to help!
Post Reply