¿Que hago si mi Personaje y mi Suelo no colisionan?

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

Mi personaje es un KinematicBody2D y el suelo un StaticBody2D; ambos nodos tienen sprite y Collision Shape2D, pero al reproducir la escena mi personaje atraviesa el suelo y no colisiona

:bust_in_silhouette: Reply From: gecko386

If you want to have a response faster, please make your questions in english.

Ahora en serio, aparte de que ambos nodos tengan las kinemáticas tienes que configurar el sistema de layers y máscaras. Esto sirve para establecer que objetos colisionen entre si.

echa un vistazo a la sección del manual de físicas

:bust_in_silhouette: Reply From: FelipeRattu

I’m not that good in spanish so i’ll write in english but you can translate this text and hopefully will work fine (falo português também se for mais fácil, se for comenta que eu traduzo), propably is some error with the collision layers settings.

click on the static body and notice that there’s a section called “collision” in the inspector tab, is haves a lot of tiny squares and two labels, one label says “layer” and the other “mask”. if you click the three dots by the side of the squares you see their names like “layer1”, “layer2” and so on…

check the layer you want the ground to be (for example “layer1”) and in mask mark the layers of things that the ground will collide with, like the player in your case, so lets say the player will be on “layer2”, so in the ground collision mask you’ll check layer two.

now head to the kinematic body you do the same but the player layer will be “layer2” and it’s mask “layer1”.

now the ground can detect the player collider and the player can detect the ground collider and everything should work fine :slight_smile:

:bust_in_silhouette: Reply From: Gosht_Navigator

jernnehy: le has dado forma a las collision shape2D? revisa el inpector, en las propiedades de collisonShape, hay una opcion llamada shape, asegurate de seleccionar una forma, tanto para tu personaje como para el suelo