Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | GoodCrafting |
I made everything exactly like in the video(https://www.youtube.com/watch?v=DjR4nKlyY4I&list=PLf0k8CBUad-v_J1Xq5XW7FEUHokxSuYnF&index=18&t=0s), but new Godot every time sends me an error:
Invalid call. Nonexistent function “distance_to” in base Vector2
rec://big.gd - 25
What did I make wrong?
I need the answer as soon as it possible
Please:
extends Sprite
const RADIUS = 75
const SMALL_RADIUS = 35
var stick_pos
var evt_index = -1
func _input(event):
if event is InputEventScreenTouch:
if event.is_pressed():
position = event.position
stick_pos = position
$small.position = Vector2()
if stick_pos.distance_to(event.position) < RADIUS:
evt_index = event.index
elif evt_index != -1:
if evt_index == event.index:
evt_index = -1
$"../".stick_speed = 0
$"../".stick_vector = Vector2()
$"../".stick_angle = 0
if evt_index != -1 && event is InputEventScreenDrag:
var dist = stick_pos.distanse_to(event.position)#here is the problem
var vect = (event.position - stick_pos).normalized()
if dist+SMALL_RADIUS > RADIUS: dist = RADIUS-SMALL_RADIUS
$"../".stick_speed = dist
$"../".stick_vector = vect
$"../".stick_angle = event.position.angle_to_point(stick_pos)
$small.position = vect
Why does my joystick work, but DOESN’T MOVE?
GoodCrafting | 2020-04-12 08:48