How to make first-person camera lock on to objects

Godot Version

v4.2.2.stable.official [15073afe3]

Question

Hello. I’m creating a first-person game that doesn’t require the player to use the mouse to look around. I am trying to make it so that the player character always faces a certain object or NPC in the game, no matter where the player moves using the WASD keys. I’ve been looking at tutorials from camera following to aim assist, but none seem to fit what I need. How would I go about doing this?

Maybe you can use Node3D.look_at()? Just call it every physics frame.

3 Likes

Thank you for the response.
What I have right now is an extension of the default first-person character controller:

var target
@onready var enemy = $“…/Enemy”
target = enemy
look_at(target.global_transform.origin, Vector3.UP)

This achieves a close result to what I want. Please excuse the terrible coding, as this is my first project. Thank you again.

1 Like

You can simplify it with target.global_position

1 Like