RE: godot collision detection mouse position

You are viewing a single comment's thread from:

godot collision detection mouse position

in godot •  7 years ago 
extends Area2D

var clckd=false
var pos_chd=false

func _ready():
    set_physics_process(false)
    pass

func _process(delta):
    if clckd:
        clckd = false
        pos_chd = true
        print('\nms click')

func _physics_process(delta):
    print(delta)
    if pos_chd:
        pos_chd=false
        print('\n pos changed')
        for a in get_overlapping_bodies() :
            print ('body: ', a.get_parent().name,'/', a.name)
        for a in get_overlapping_areas():
            print ('area: ', a.get_parent().name,'/', a.name)
        set_physics_process(false)
    pass
    
func _input(e):
    if (e is InputEventMouseButton
    and e.button_index == BUTTON_LEFT and not e.pressed) :
        position = get_global_mouse_position()
        clckd = true
        set_physics_process(true)
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!