Godot Version
4.2
Question
I have been struggling to get something that should be seemingly simple to work. I want the collision activated from my Area2D node (which follows my cursor and activates a hitbox when left mouse button is pressed) to interact with a RigidBody2D node that is scrolling across the screen. When they collide, I simply want to queue_free() the RigidBody2D.
I know that Area2D and RigidBody2D hitboxes cannot naturally interact, so using the hitbox signal on the RigidBody2D wasn’t working. The only solutions I have come across simply suggest they both be physics2d bodies or area2d nodes. However, changing the Area2D node to a physics body ends up pushing the RigidBody2D around with the hitbox and not actually ever triggering the signal function to queue_free().
I also saw a suggestion to use the collision signal on the Area2D node instead, but I am unaware on how I would call a function from a separate node in the Area2D script. I could call it from the main node script, but the RigidBody2D is being instantiated through a script so the signal isn’t present to be connected.
I’ve also tried changing both of them to be Area2D, with the first node being moved across the screen every frame in its own _process function. For some reason this didn’t work either, despite updating the script to use the new _on_area_entered signal and connected it to itself just like you would with the _on_body_entered signal.
I’ve enabled Visible Collision Shapes to ensure the collision hitboxes are actually present, and they are.
I’m very new to godot so I know I’m missing something, it’s just frustrating to me that I got stuck here despite how simple it must be.
edit: having both of them be Area2D does in fact work, it only wasn’t in my testing because the hitbox wasn’t active long enough. I’m unsure how to fix this properly, I’ve tried creating and using await on a timer between enabling and disabling the hitbox, but it breaks.