This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

I want to get a look at point above my character while using look_at(Vector3 target, Vector3 up). The idea is that I want to set the camera position and rotation in editor. Then I want the camera to keep looking at that same direction while following the charter movement with look_at function. Using the character's location vector changes the camera's original looking direction which is exactly what I want to avoid. I hope next image clears things a little bit.

in Engine by (63 points)
edited by

1 Answer

0 votes
Best answer

I found one solution. First save the original rotation of the camera. Then set the camera to look at the target (character). Now calculate the offset value and apply it every time after using the look_at() function. Here's the code.

camera.look_at(character_pos, Vector3.UP) 

if check_only_once:
    check_only_once = false
    cam_rotation_offset = camera_original_rotation-camera.rotation
by (63 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.