Topic was automatically imported from the old Question2Answer platform.
Asked By
x4rkz
I have an Area2D (a character) who has several collisions shapes, one for his body, one is a large circle around him which is its range to detect object.
Is it possible to put each collision shape in a different layer object? Because I want the first collision shape to only collide with other characters, and the second one to only collide with objects (another node of type Area2D).
Unless, the only solution is to distinguish collisions (process some and ignore others) in the code? Because as far as I know, only an area2D can have a collision layer, not his collisions shapes.
Or maybe, it’s good practice to define the node tree like this?
Multiple collision shapes on one Area2D still define only one area, so they will act like one large one.
If you want the shapes to have different functionality, then yes, you need them to be separate Area2D nodes. These can then be put on different collision layers, have different code for area_entered, etc.
What you choose for your root node depends on what you want it to do. In your example, it could be the Sprite. If it needs collision, maybe a KinematicBody2D, etc. Try it a few ways and see what makes the most sense for your needs.
kidscancode | 2019-09-08 19:10
Okay but it is still unclear to me if I need can do this: