I am trying to drag and drop a RigidBody2D, however I have noticed that my code doesn't work at all if I set the Gravity Scale = 0 and if I set the Gravity Scale to 0.5 it works however if I drag it and stop moving the mouse for a second, it gets stuck in its place as if I did set the Gravity Scale to 0.
var is_held = false
var lv = state.get_linear_velocity()
lv = (get_viewport().get_mouse_pos() - get_pos()) * 16
if event.type == InputEvent.MOUSE_BUTTON and not event.pressed and event.button_index == BUTTON_LEFT:
is_held = false
func _on_food_input_event( viewport, event, shape_idx ):
if event.type == InputEvent.MOUSE_BUTTON and event.pressed and event.button_index == BUTTON_LEFT:
is_held = true
In the end what I am trying is to be able to drag and drop the rigid body either vertically or horizontally and not both nor diagonal.