I need help with a 3d camera and its relative movement

Godot Version

Godot 4.6.2.stable

Question

I’ve tried multiple times to make a camera with relative movement, but I can’t make anything work, I just wanted to know if anyone has any suggestions/ tutorials, I’m willing to change versions if it helps

If you share code, please wrap it inside three backticks or replace the code in the next block:

func _ready() -> void:
    print("hello world")

What’s “relative movement”? Relative to what?

to the camera, I want to turn a 3rd person camera and still move forward so if I turn the camera completely around, I want the player to turn around and move in the new forward direction

You want player movement to be relative to camera’s viewing direction? Project the input directions to x and z axes and then project the result onto horizontal plane.

Two things to keep in mind:

  • You track your camera independent to the player
  • The player can access the camera.

So, to allow the player to face the model toward the camera direction this snippets could help:

	# Get the input direction and handle the movement/deceleration.
	var direction = Vector3(input_dir.x, 0, input_dir.y).rotated(Vector3.UP, _camera_mount.rotation.y)

I’m sorry I still don’t understand, should I show my camera script? the most common issue is the line doesn’t recognize “_camera”

You’re scene has a camera so you need to retrieve it. usually on ready but you can set it manually too.
Auto

@onready var camera : Camera3D = camera_mount.get_node("Camera3D")

or

var camera: Camera3D = get_viewport().get_camera_3d()

Manual

var _camera_mount : Node3D

Depends on your implementation