I'm currently messing around with making a kind of physics game and I would like the player to be able to use their mouse to essentially pick up objects.
The code currently looks like this
extends RigidBody2D
var mouse_inside = false
func _physics_process(delta):
if Input.is_action_pressed("click"):
global_position = get_global_mouse_position()
func _on_metalCube_mouse_entered():
mouse_inside = true
func _on_metalCube_mouse_exited():
mouse_inside = false
This 'works,' but not in the way that's intended. I'm currently not using the mouse_inside boolean because it does nothing. This is mostly because of the mouse_entered/exited function. It doesn't seem to work properly. For some reason the Area2D that the function is connected to thinks that once my mouse enters the (seemingly) the hitbox of the item my mouse is exiting the Area2D. Basically, it only detects the mouse properly if the mouse does not enter both the Area2D and the items hitbox itself.
How would I go about fixing this?