Getting the object that was collided with Kinematic 2D bodies

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

I’m trying to change the sprite of the player object (2D kinematic body) into the object that was collided with.

I’ve been able to get to a point where the sprite changes into a different sprite, but I can’t seem to find a function that returns the object that was collided with.

Everything is under a 2D Node, and my movement is done with 8-way movement, using the standard WASD format.

Any help would be appreciated.

:bust_in_silhouette: Reply From: kidscancode

The answer depends on how you’re moving your KinematicBody2D. Please see this article in the docs: