Это сложная идея, чтобы задать вопрос, я создал систему, в которой игрок рисует круги на экране, я хочу, чтобы игрок либо коснулся другой своей линии, начал новый круг из этой позиции, проблема, с которой я столкнулся, заключается в не имея представления о том, как я могу заставить его столкнуться, у меня есть идея, но я не уверен, сработает ли она, моя идея слишком просто использовать другую форму столкновения, которая создает себя в точках, которые соединяются друг с другом, и когда мышь сталкивается с этим Определенная форма столкновения начинается снова, это лучший вариант, который у меня есть, или есть другой способ определить, когда создается круг.
Вот видео о том, что я хочу: https://youtu.be/wSolVcaIszE?t=998
и вот мое видео о том, что у меня есть: https://www.youtube.com/watch?v=BDnd-n3PEdQ
код:
extends Node2D
var points_array = PoolVector2Array()
var index : int = 0
onready var collision = $Area2D/CollisionPolygon2D
func _physics_process(delta):
collision.polygon = points_array
if Input.is_action_just_pressed("Left_click"): #This sets a position so that the next line can work together
points_array.append(get_global_mouse_position()) # This makes a empty vector and the mouse cords is assigned too it
points_array.append(Vector2())
if Input.is_action_pressed("Left_click"): #This checks the distance between last vector and the mouse vector
points_array[-1] = get_global_mouse_position() # Gets the last position of the array and sets the mouse cords
if points_array[index].distance_to(get_global_mouse_position()) > 20:
points_array.append(get_global_mouse_position())
index += 1
if points_array.size() > 25: # This adds a length to the circle/line so it wont pass 18 mini lines
index -= 1
points_array.remove(0) #Removes the first array to make it look like it has a length
if Input.is_action_just_released("Left_click"): # This just clears the screen when the player releases the button
points_array = PoolVector2Array()
index = 0