KinematicBody2D with multiple collision shapes

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

I am trying to make a 2D game and I have a KinematicBody2D character that has a small collision shape specifically for the walking animation. (I want the player to walk up until his knees against a wall as if he was standing in front of it. When I first made it, the player would collide as soon as his had hit a wall.)

Now I want to let the user interact with objects for example picking something up. The problem is that it only works with the collision shape that I made for the walking animation. This means that the player can only pick up items with its knees.
I tried to add a second collision shape to player but it will then register both collision shapes which solve this problem but then the player would again bump its head against a wall instead of its knees.

Which brings me down to my actual question:
How can I have an object with multiple collision shapes with separate functions?

In my case:
Player has collision shapes walk_collision that collides with walls only and interact_collision that collides only with ground objects.

:bust_in_silhouette: Reply From: TyTYctA

I think you can make many collision and
enter image description here

Then using disable property of collison shape for active or deactive them
enter image description here
enter image description here

But how do I then implement it for the different objects?
If I disable for example the interactcollision then it won’t interact with any items. When do I need to turn the collisions on and off because I only know when to disable it after I already collided with a wall, when it is too late.
I want the collision shapes of wall and walkcollision and of item and interactcollision to collide only.

Maurits | 2019-02-24 09:49

You may use Area2D for additional collision
enter image description here

change Collision Layer of Item to Pick Up
change Collision Layer to Pick Up

Change MaskCollison of Interact_Area to Pick Up
enter image description here

Change MaskCollison of Player to Terrain
enter image description here

Then use signal area_enter of Item to detect Interact_Area

TyTYctA | 2019-02-25 01:55

I works now thank you.

Maurits | 2019-02-25 12:02