How do I detect when two objects are touching in Godot 4?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By LucasTheDingus

I have two Sprite2D nodes with CollisionShape2D nodes as child nodes to them. How do I use GDscript to detect when they are touching?

:bust_in_silhouette: Reply From: Moreus

If you want use Godot collisions You needed PhisicBody2D like RigidBody2D. if you read asterisk you will know that already. Next you use signals, they usually next tab after inspector.
also you can check this tutorial from Godot 3

other way you make own calculations for collisions