This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

Allow me to explain my issue, I am using an Area2D node as something that the player has to click on to earn points, and I would like to know how I could make the click detection work for all nodes in a group, I've added my Area2D node to a group, and I have to instance it. Nothing happens when I click the instances, only when I click the original node.

extends Node2D

var score = 0

onready var clickme = preload("res://assets/ClickMe.tscn")
onready var clickmeinstance = clickme.instance()

func _on_ClickMe_input_event(_viewport, _event, _shape_idx):
    if Input.is_mouse_button_pressed(1):
        score+=1
        clickmeinstance.position = Vector2(rand_range(0, 320), rand_range(0, 240)).round()
        get_tree().get_root().call_deferred("add_child", clickmeinstance)
        get_node("CanvasLayer/Score/ScoreLabel").text = str(score)
Godot version 3.3.3.stable
in Engine by (32 points)

is the collision polygon present in the instanced areas?
you can check by running the project with visible collision shapes enable (top screen, debug=>visible collision shape)

I just checked, the collision Polygon is indeed present.

Is it possible the problem lies on adding the new instance as child of the root?
Also, just to exclude there is nothing wrong with the scene, does it work if you instance it in a less fancy way? (Eg: create many instances on the ready of the parent, through a for loop)

I don't know much about for loops and my game needs to instance the node when I click the one that came before

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.