Making character always go in front of camera.

Godot Version

4.3 stable

Question

Hi, so I have this idea about making game played from camera operator view. I want to always have journalist appear in front of first person camera. Like when player turns camera npc follows it to be in front, when player moves so do npc. Any help is greatly appreacieted!

1 Like

Phantom camera will probably be enough:

1 Like

As far as I understood, the NPC should follow the camera and try to stay inside the camera frustum. Phantom Camera is doing the opposite: It makes the camera follow a moving target.

To achieve the goal of OP, you could do the following:

  • Find the forward vector of your camera (cf. Basis — Godot Engine (stable) documentation in English) e.g. camera.global_basis.z
  • Determine a point in front of the camera (e.g. simply do camera.global_position + 5 * forward_vector)
  • Use this as the target position of your journalist and make the journalist lerp() or move_and_slide() towards the target.

Hope this helps and gives you an idea! :slightly_smiling_face:

2 Likes