Why is my Vector2 classified as 'Callable'

Godot Version

4.3

Question

Help Programming gdscript
As title says, I do not understand why my variable that’s supposed to be a Vector2 is classified as type ‘Callable’

This is the line that gives me the error:

var dir:Vector2 = to_local(navAgent.get_next_path_position()).normalized

This is the full code if it’s needed:

extends CharacterBody2D

const SPEED:float = 300.0
const humanShader:Resource = preload("res://other/shaders/shirtColor.gdshader")
const passengerShader:Resource = preload("res://other/shaders/passenger.gdshader")
var isPassenger:bool = false
var rng:RandomNumberGenerator

@onready var sprite:Sprite2D = $Sprite2D

var shirt:Vector4
#enum states {IDLE=0, WALK=1, TRANSPORTING=2}
#var curState = states.IDLE
@onready var navAgent:NavigationAgent2D = $NavigationAgent2D
	
func _ready() -> void: #Gives a random skin to the passenger
	if isPassenger == false: remove_child($Area2D2)
	rng = RandomNumberGenerator.new()
	var red = rng.randf_range(0.00,1.00); var green = rng.randf_range(0.00,1.00); var blue = rng.randf_range(0.00,1.00)
	shirt = Vector4(red, green, blue, 1)
	rng = RandomNumberGenerator.new()
	check_shader()
	var weights = PackedFloat32Array([0.7, 1, 0.1, 1, 1])
	var randomNumber:int = rng.rand_weighted(weights)
	match randomNumber:
		0: sprite.texture = load("res://sprites/npcs/baldMan.png")
		1: sprite.texture = load("res://sprites/npcs/hoodieMan.png")
		2: sprite.texture = load("res://sprites/npcs/jonkler.png")
		3: sprite.texture = load("res://sprites/npcs/man.png")
		4: sprite.texture = load("res://sprites/npcs/woman.png")
	rng = null
	call_deferred("actor_setup")

func actor_setup():
	await get_tree().physics_frame
	navAgent.set_target_position(get_parent().get_parent().get_random_walkable())
	
var random:int

func _physics_process(delta: float) -> void:
	if isPassenger:
		if sprite.material.shader != passengerShader: 
			sprite.material = ShaderMaterial.new()
			sprite.material.shader = Shader.new()
			sprite.material.shader = passengerShader
			#if not $Area2D2.is_in_group("Passenger"): $Area2D2.add_to_group("Passenger")
	else:
		walk()
		#if $Area2D2.is_in_group("Passenger"): $Area2D2.remove_from_group("Passenger")

	move_and_slide()

func update_passenger() -> void:
	rng = RandomNumberGenerator.new()
	var randomNumber = rng.randf_range(0, 100)
	if randomNumber == 1: isPassenger = true
	if isPassenger == true: sprite.material.shader = passengerShader
	else: sprite.material.shader = humanShader
	rng = null

func _visible_entered() -> void:
	sprite.visible = true
	check_shader()

func _visible_exited() -> void:
	sprite.material.shader = null
	sprite.visible = false

func check_shader() -> void: 
	sprite.material = ShaderMaterial.new()
	if isPassenger: sprite.material.shader = passengerShader
	else: sprite.material.shader = humanShader
	sprite.material.set_shader_parameter("old_color", Vector4(1,1,1,1))
	sprite.material.set_shader_parameter("new_color", shirt)
	
var hasPath:bool = false

func walk() -> void:
	if navAgent.is_navigation_finished():
		actor_setup()
	var dir:Vector2 = to_local(navAgent.get_next_path_position()).normalized
	velocity = dir * SPEED

Any help is appreciated, thanks in advance.

normalized is a method/callable, you need to add parenthesis to call it

var dir:Vector2 = to_local(navAgent.get_next_path_position()).normalized()
2 Likes

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