- Edited
Hi All,
I've got two questions that I hope you guys can help me with. First, let me show you what I have:
One KinematicBody2D with a Label attached to it (let's call this the Player). The ground is a StaticBody2D (I'm showing the collision shapes)
The Label shows the name of the object the KinematicBody2D is colliding with as per below:
move_and_slide(motion, UP)
if get_slide_count()==1:
$Label.text = get_slide_collision(0).get_collider().name
if get_slide_count()=2:
$Label.text = get_slide_collision(0).get_collider().name +"/"+ get_slide_collision(1).get_collider().name
The above is inside the Player's _physics_process.
Question 1: When I move my KinematicBody2D (and only when I move) I get:
ie. There are two collisions with the same ground in the same _physics_process. Is this normal?? (I ask because it may be related to the bug below)
Question 2: If I have the Player (KinematicBody2d + debug label + Gravity) and another KinematicBody2D (let's call it Fly2, it follows the player), I get this:
ie. The player collides with Fly2 twice in the same _physics_process. Also, they keep jittering and the player is kind of trapped (I have to move it using the keyboard a few times before it actually moves). Why is this happening (notice they overlap a bit, I guess this is related) and how do I fix it?
Bonus question: how do I put tabs in a code tag in this Markdown? (so that my ifs are correct in the future)
Thanks!!!