https://imgur.com/a/TydnsgC <= Example

Hey guys,
I want to create a circle as a target 2d and being able to catch the mousepressedon on that circle. If it is pressed in the middle it should give max amount of points per hit, let's say 100, if it is pressed away from the center (inside the circle) it should give x points depending on the distance from the center point, if outside = 0points.
I am pretty new to the Godot and I don't know how to solve this issue. I have no script for this scene yet and I am not sure if I should use CollisionShape2D or something else for the circle and etc. I would appreciate it if anyone could help it out and guide me in solving this issue. Thanks, fellas.

in Engine

Use an Area2D with a CollisionShape2D set to "Circle". Area2D has input capability - connect its `input_event` signal, and check for mouse click events.

Next, measure the distance from the click position to the area's position (the center of the circle), and assign your points.

``````func input_event(viewport, event, shape_index):
if event is InputEventMouseButton and event.pressed:
var distance_from_center = position.distance_to(event.position)
``````

Alternatively, you could add multiple CollisionShape2D circles of varying radius, and use the `shape_index` property to see which one was clicked, using that to assign points.

by (20,479 points)
selected by

Thanks for your answer, I am getting the distance from the center! Amazing :) Maybe you know the syntax of getting the center? Because I want to assign some points to the very center of the Area2D. var center = ?
The center of the collision shape is its `position`. But this will probably be `(0, 0)` if you call it on the collision shape since it's relative to the parent. Use the area's `position` for that. Or if you need global coordinates, `global_position`.