godot collision detection mouse positionsteemCreated with Sketch.

in godot •  7 years ago 
extends Area2D

var clckd=false
var pos_chd=false

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

func _physics_process(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)
    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
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!
Sort Order:  
Loading...