How to make a target?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By KiraArts

Hello, a little large cuestion.
I want to do a targen/bullseye with points for each circle, like the little one, give 300, the second 200, the other 100 and the bigger one 50, but i’m not sure how to do that.
The image:
I made a sprite for each circle and put this code:

func _input(event):
if event is InputEventMouseButton and event.pressed and event.button_index == BUTTON_LEFT:
	if get_rect().has_point(get_local_mouse_position()):
		if event.pressed:
			P200 = true
			print("Not pressed")

and it works, when i press the center circle, it prints “300”, but also “200”, “100” and “50”. when I press the second one, it prints “200”, “100”, “50” (I only want 200).
How can I get only one number?
I tried with signals:

and this code in the node2D:

p300 = false
p200 = false
p100 = false
p50 = false

with each signal, changes with true (emit_signal(“click300”), in the node2D: P300 = true)

if P300 == true:
   p200 = false
   p100 = false
   p50 = false

And this with p200, p200 and p50.
The problem is that the first time, always prints “50”, and, if I press 200, it prints “200”, ok, but if I press any other, it will print “200” again.
Any one have the solution or another method?

:bust_in_silhouette: Reply From: stormreaver

When I made my VR darts game, I divided the board into rings and segments. The rings were indicated by a starting and ending distance from the center of the board and the segments were indicated by degrees around the circle (you don’t need this part).

After I detected where on the board the dart tip landed (the KinematicCollision contains that point), I simply calculated the vector’s length (which is the same as the distance from the board’s center) and then determined which ring contained that distance.

Hello, sorry, I still don’t handle godot very well, could you tell me how to do that? thank you.

KiraArts | 2023-04-28 00:59

I suggest reading up on KinematicBody, it’s move_and_collide method and the KinematicCollision object. I’m assuming you are already a somewhat familiar with vectors. If not, you will need a basic understanding of how vectors work. Godot has functions that do the math, but you need to understand the when’s and why’s.

stormreaver | 2023-04-28 01:16