Collision detection independent of a KinematicBody

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

I would like to use a collision shape to detect whether there is room for the player character to move into a space before allowing the action to do so.

Therefore, I would like to use another collision shape, roughly the size of the player, which hovers ahead of the player character and is checked when the action is attempted.

As far as I understand things, CollisionShapes don’t really work on their own, they must be children of a Node that can use them; for instance, my player’s KinematicBody which contains collisionShape children that are used for move_and_slide().

So my thought was to reparent my Player’s KinematicBody to a Spatial Node which can then have another child of some kind that utilizes this separate floating CollisionShape. In this way, the new collisionShape would be a sibling, rather than a child, of my Player Node.

Would that be an efficient way to do this? Perhaps there is a better way to do this such that the new CollisionShape is still a child of my KinematicBody but is not used for move_and_slide? And would the new CollisionShape need to be the child of a new ‘Body’ Node, such as StaticBody?

Thank you muchly for any ideas you might have!

:bust_in_silhouette: Reply From: tmcahill

Figured this out, added a child ‘Area’ node with it’s own collision shape that is able to detect collisions independent of its parent KinematicBody.