- Home /
Adjust LookAt
I use the LookAt() function so my player will look at a character when the character gets next to him. Before doing that, the player can move around the scene using the W key and mouse as a first person. When the character is next to the player, I disable the player's ability to move and then do the LookAt() function. It does fine to point the player to the character. The problem is that if the player was looking at the ground or the sky before the character got to him, the player continues to look in the same direction, either up or down, though his body is pointing toward the character. I was wondering what command I need to use after the LookAt() command to have him look perfectly horizontally and not up or down.
Answer by MarkWaldo · Apr 16 at 02:09 AM
[Answer] I found the problem. The player is a capsule and its eyes are a component camera. I was having the capsule as the transform for the LookAt() instead of the player's eyes (the camera). By using the camera's transform, it correctly points to the character using Lookat(). regardless of what it was pointing at before.
Your answer
Follow this Question
Related Questions
Fixed Camera Scene a la FF7 or Resident Evil style 2 Answers
I need to add force based on the angle I'm looking at the object. 1 Answer
Instantiated Object - Look At. 1 Answer
2D tranform.lookAt Problem 1 Answer
crane lifting cylinder held by fixed joint moves out of position when i rotate crane. 0 Answers