How to prevent KinematicBody2D from running over walls and emit body_enter at the same time?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Rodrigo Alves
:warning: Old Version Published before Godot 3 was released.

I want my char to collide with walls so I did a tree like this:

Although I also want to do somethig if it collide with other things, so Godot Tutorial said that I should add and Area2D to the Wizard so that I could emit the body_enter/area_enter signals. But if I do my tree like this

My char runs over walls. How can I prevent my char from running over walls and also be able to decide what he should do when hit on something else in the game? Should I add 2 collision shapes like this:

But is it correct?

:bust_in_silhouette: Reply From: eons

Yes, the last is correct, is just a composition of CollisionObjects.

The CollisionShape nodes are adding the shape to the parent in runtime, that and debugging information is all what they do (at least on Godot 2.x).

Remember to use different layer/mask pairs so the area do not detect the parent body (if using body_enter).