This is a hard idea to put into a question, I have made a system where the player draws circles on screen, I want the player has either touched another line of its self start a new circle from that position, the issue I am having is having no clue on how would I make it collide, I have an idea but not sure if it will work, my idea is too simply use a different collision shape that creates its self on points that connect each other and when the mouse collides with that specific collision shape start again, is this the best option I have or is there another way of detecting when a circle is made.
heres a video of what I want: https://youtu.be/wSolVcaIszE?t=998
and heres my video of what I have: https://www.youtube.com/watch?v=BDnd-n3PEdQ
code:
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