Hello, im trying to add aiming down the sight with my gun in my 3d fps and i keep getting the error Invalid access to property or key 'fov' on a base object of type 'Camera3D'.

Godot Version

4.7

Question

Like title says i keep getting the error ‘Invalid access to property or key ‘fov’ on a base object of type ‘Camera3D’.’ as soon as i start running my game and I do not understand how to fix it.

extends Node3D


@export var default_position : Vector3
@export var ads_position : Vector3
@export var ads_acceleration : float = 0.3
@export var default_fov : float = 75
@export var ads_fov : float = 75
@export var camera_3d : Camera3D

func _ready():
	default_fov = camera_3d.fov
	default_position = camera_3d.position
	ads_fov = camera_3d.fov
	ads_position = camera_3d.position
	
func _process(_delta):
	if Input.is_action_just_pressed("ads"):
		transform.origin = transform.origin.lerp(ads_position, ads_acceleration)
		Camera3D.fov = lerp(Camera3D.fov, ads_fov, ads_acceleration)
	else:
		transform.origin = transform.origin.lerp(default_position, ads_acceleration)
		Camera3D.fov = lerp(Camera3D.fov, default_fov, ads_acceleration)

Camera3D is the type, it’s not a real camera, like how a blueprint of a house isn’t a real house. camera_3d is your variable you should be using .fov.

Also Input.is_action_just_pressed will only run for the single frame, you probably want Input.is_action_pressed to check every frame and interpolate.