Hello something fast

Godot Version

4.4

Question

hello, im trying to make the camera look at the player

extends Camera3D

@onready var player: CharacterBody3D = $"../player"


var target = player.position

func _process(delta):
	look_at(target)

i tried with this code but it gives me an this mesage "The parameter “delta” is never used in the function “_process()”. If this is intended, prefix it with an underscore: “_delta”.
UNUSED_PARAMETER
camera_3d (2).gd:8
"

That’s a warning, not an error. You can ignore it if you like.

You can fix it by changing your code to read:

func _process(_delta):
    [whatever...]

“Unused parameter” means the function is taking an argument (delta) that isn’t used anywhere in the function. The warning is based on the assumption that if you handed an argument to a function it was probably for a reason, so it complains when you do nothing with it. That assumption doesn’t hold for everything.

1 Like

The warning only states that delta is unused, and tells you how to dismiss the warning.

The real error is copying the player’s position as target, a Vector3 is not referenced so making a new variable will copy the value once, then never updated.

And since var happens before @onready you are trying to get the position before the player variable is ready.

Ultimately you should use player.position instead of target.

extends Camera3D

@onready var player: CharacterBody3D = $"../player"

func _process(_delta):
	look_at(player.global_position)
1 Like

thankx man u are correct :cowboy_hat_face:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.