#Area 2d dont work

1 messages · Page 1 of 1 (latest)

chrome notch
#

Hello, I am encountering a problem that I do not understand, I have 2 scenes, 1 with a large object which has a 2d area and another with a small object that I can move with my mouse, it has been 2 hours since I tried to do that if I put the small object in the large object or message is displayed in the console but I can't find a solution. If anyone can help me I would appreciate it.

gilded fractal
#

I don’t quite understand the issue from your wording. What should be happening? And what wrong thing is happening instead?

chrome notch
gilded fractal
chrome notch
gilded fractal
#

Show the code

chrome notch
#

var mouse_offset

var selected = false

# Called when the node enters the scene tree for the first time.
func _ready():
    pass # Replace with function body.

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
    if selected:
        followMouse()
        
func followMouse():
    position = get_global_mouse_position() + mouse_offset


func _on_area_2d_input_event(viewport, event, shape_idx):
    if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
        if event.pressed:
            mouse_offset = position - get_global_mouse_position()
            selected = true
        else :
            selected = false
            




func _on_area_2d_body_entered(body):
    print("object 1 is in object 2")```
#

this is the code for the object on the right

gilded fractal
#

did you change the collision layers perhaps?

chrome notch
#

they are in the first layer

warped stream