#How do I fix this error
19 messages · Page 1 of 1 (latest)
What are you trying to do with :Vector2?
Idk someone told me this would work in finding the distance between two things
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
Well since distance is a float would I replace vector 2 with float?
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
ok thanks
uhm I have another problem
now the character spawns directly on the note, and can't move
May I give you my movement code. It's for platformers
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?
At no point in this code are you setting the player or note variables to anything. Then, every frame you are setting the position of your player node to that empty vector2, which I'm pretty sure would just default to Vector2(0,0), which is why they both spawn at the same spot and your character chan't move
Just confirmed that an empty Vector2 variable defaults to Vector2(0,0)