Godot Version
4.3
Question
im trying to get a card to just simply click and drag, following the tutorial and going back and forth to double check the code, and even reading it my self, i cant for the life of me figure out why im unable to drag the card along the screen TwT
var card_being_drag
func Area2D_check_for_card():
pass
func _process(delta: float) -> void:
if card_being_drag:
var mouse_pos = get_global_mouse_position()
card_being_drag.position = mouse_pos
func _input(event):
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
if event.pressed:
var card = Area2D_check_for_card()
if card:
card_being_drag = card
else:
card_being_drag = null
func raycast_check_for_card():
var space_state = get_world_2d().direct_space_state
var parameters = PhysicsPointQueryParameters2D.new()
parameters.position = get_global_mouse_position()
parameters.collide_with_areas = true
parameters.collision_mask = 1
var result = space_state.intersect_point(parameters)
if result.size() > 0:
print(result[0].collider.get_parent())
return null