No constructor of Vector2 matches the signature Vector2

finding a fix to these code errors?
No constructor of “Vector2” matches the signature “Vector2(int, float, float)”.
Line 27:No constructor of “Vector2” matches the signature “Vector2(int, float, float)”.
Line 28:No constructor of “Vector2” matches the signature “Vector2(float, float, int)”.
Line 29:No constructor of “Vector2” matches the signature “Vector2(float, float, int)”.

Code:
extends CenterContainer

@export var RETICLE_LINES : Array[Line2D]
@export var PlAYER_CONTROLLER : CharacterBody3D
@export var RETICLE_SPEED : float = 0.25
@export var RETICLE_DISTANCE : float = 2.0
@export var DOT_COLOR : Color = Color.WHITE
@export var DOT_RADIUS : float = 1.0

func _ready():
queue_redraw()

func _process(delta):
adjust_reticle_lines()

func _draw():
draw_circle(Vector2(0,0),DOT_RADIUS,DOT_COLOR)

func adjust_reticle_lines():
var vel = PlAYER_CONTROLLER.get_real_velocity()
var origin = Vector3(0,0,0)
var pos = Vector2(0,0)
var speed = origin.distance_to(vel)

RETICLE_LINES[0].postion = lerp(RETICLE_LINES[0].position, pos + Vector2(0, -speed, RETICLE_DISTANCE), RETICLE_SPEED)#top
RETICLE_LINES[1].postion = lerp(RETICLE_LINES[1].position, pos + Vector2(0, speed, RETICLE_DISTANCE), RETICLE_SPEED)
RETICLE_LINES[2].postion = lerp(RETICLE_LINES[2].position, pos + Vector2(speed, RETICLE_DISTANCE,0), RETICLE_SPEED)
RETICLE_LINES[3].postion = lerp(RETICLE_LINES[3].position, pos + Vector2(-speed, RETICLE_DISTANCE,0), RETICLE_SPEED)

In the last 4 lines you are trying to put 3 numbers into a Vector2 struct, which accepts only 2 numbers.
E.g. here:

Vector2(0, -speed, RETICLE_DISTANCE)

You need to remove one of these numbers.

4 Likes

thank you, just one thing there is a tutorial i was watching where he set it as such
here is the link
https://www.youtube.com/watch?v=B-PvZgVdU4o part1
https://www.youtube.com/watch?v=xI_i2K9kAOw part 2

Watch the tutorial again then, because his formulas are different to yours.
Don’t just blindly copy the code, but instead try to understand the meaning behind it.

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