Godot Version
4.2.2
Question
Hi, I’m new to Godot in 3D and I’m making a racing game. I want a camera to smoothly follow the car instead of being attached to it and following all of its movements. How can I do this?
4.2.2
Hi, I’m new to Godot in 3D and I’m making a racing game. I want a camera to smoothly follow the car instead of being attached to it and following all of its movements. How can I do this?
Two approaches:
extends Camera3D
@export var follow_target: Node3D
@export var look_target: Node3D
Those two nodes can be children of the car object - these are the ones we’ll try to smoothly follow.
Then, you can start with a script that just keeps the camera right on the follow target - this is not the end result you want, just a starting point:
func _process(delta):
global_position = follow_target.global_position
look_at(look_target)
From there, you can use functions like lerp
, move_toward
, and similar to smooth out the movement, rather than just setting the camera’s position to the follow target’s position.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.