How to get all collisions (not move_and_slide only) on a characterbody?

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

I essentially want something similar to Rigidbody: contact_monitor (for signals). Is there a way to access that data for a CharacterBody2D?

:bust_in_silhouette: Reply From: mikefrom1974

move_and_slide should still get you all the collisions…They are stored in an array that you should be able to iterate through… i.e:

func _physics_process(delta):
   # Iterate through all collisions that occurred this frame
   for index in range(get_slide_collision_count()):
       # get the specific collision
       var collision = get_slide_collision(index)

       # ignore ground
       if (collision.get_collider() == null):

       # check if the collision is something you care about
       if collision.get_collider().is_in_group("my_group"):
           var other_thing = collision.get_collider()
           # do something with this collision