mirror of
https://github.com/Cookie-CHR/OfficeMadness-LD51.git
synced 2024-11-23 15:14:18 +00:00
17 lines
446 B
GDScript3
17 lines
446 B
GDScript3
|
extends KinematicBody2D
|
||
|
|
||
|
# Pickable needs to be selected from the inspector
|
||
|
|
||
|
var can_grab = false
|
||
|
var grabbed_offset = Vector2()
|
||
|
|
||
|
func _input_event(viewport, event, shape_idx):
|
||
|
if event is InputEventMouseButton:
|
||
|
can_grab = event.is_pressed()
|
||
|
grabbed_offset = position - get_global_mouse_position()
|
||
|
|
||
|
func _process(delta):
|
||
|
if Input.is_mouse_button_pressed(BUTTON_LEFT) and can_grab:
|
||
|
position = get_global_mouse_position() + grabbed_offset
|
||
|
|