Page 1 of 1

Adding turn speed to LookAt disrupts the camera angle

Posted: Mon May 29, 2023 8:06 am
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);

Re: Adding turn speed to LookAt disrupts the camera angle

Posted: Mon May 29, 2023 8:56 am
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);

Re: Adding turn speed to LookAt disrupts the camera angle

Posted: Mon May 29, 2023 12:00 pm
by HeraldDeus
Yes the camera is a child of the player. Your code seemed to do the job, thank you!

Re: Adding turn speed to LookAt disrupts the camera angle

Posted: Mon May 29, 2023 3:08 pm
by Tony Li
Glad to help!