#How do I fix this error

19 messages · Page 1 of 1 (latest)

steel cedar
#
    $"../Player".position = player
    $".".position = note
    distance = player.distance_to(note):Vector2```
obtuse belfry
#

What are you trying to do with :Vector2?

steel cedar
obtuse belfry
#

Okay, well :Vector2 in this case should simply be removed, whatever the purpose of that was it needs to be done differently. This will get rid of the error

steel cedar
obtuse belfry
#

No, that won't fix it. The syntax : Vector2 is trying to declare the static type Vector2 but where it's placed it it's only causing an error because that should be the end of the statement but it's getting a : that it doesn't need nor want

steel cedar
#

ok thanks

#

uhm I have another problem

#

now the character spawns directly on the note, and can't move

molten jackal
molten jackal
#

Wdym

#

What kind of game are you making

steel cedar
#

I don’t have a problem with the movement code

#

I have a problem with this code

#

var player: Vector2
var note: Vector2
var distance: float
# Called when the node enters the scene tree for the first time.
func _ready():
    pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
    FindDistance()


func _on_clickbox_input_event(viewport, event, shape_idx):
    if distance >= 500:
        if event is InputEventMouseButton:
            if event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
                print("noteshown")


func FindDistance():
    $"../Player".position = player
    $".".position = note 
    distance = player.distance_to(note)`` it Caused my player to spawn directly onto the note and not have the ability to move, how do I fix this?
obtuse belfry
#

Just confirmed that an empty Vector2 variable defaults to Vector2(0,0)