how do i get the node name that a rigidbody2d collides with

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

I’m fairly new to Godot engine and I want to know how I can get the name of a body that collides with the rigid body player. Is there a way I can get the name of the collider and the position?

:bust_in_silhouette: Reply From: ramazan

Use signal

func _on_RigidBody2D_body_entered(body):
      if body:
           print(body.name) // only name
           print(body.global_position)
  pass

Rigidbody / contact_monitor = true
Rigidbody /contacts_reported = must be greater than 0 “zero”