Why my chicken wont stay on ground (no collision)

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

Here’s what I did:

I have a KinematicBody2D as my Player, and a StaticBody2D as my wall (floor), and nother one on top. Both them have CollisionShape2D as rectangles which cover their sizes. My Chicken (the player) has gravity, so it fells. However, it passes through the wall without anything happening.

What am I missing?

You should probably share your code, as it could be something to do with how you’re moving the KinematicBody2D. What’s with the shader attached to the collision shape?

kidscancode | 2019-03-21 01:21

is code needed to make collision happen? Anyways, here’s the code

GitHub - lattice0/godot_project1 at 507062040aef44cbfccdc0bbbdc584a143a71ba2

guerlando | 2019-03-21 02:43

:bust_in_silhouette: Reply From: kidscancode

Thanks for linking your code.

You are not using KinematicBody2D correctly. In order for the body to detect collisions, it must be moved using one of the movement methods: move_and_collide() or move_and_slide(). You can’t just set its position directly.

See the following documentation: