Why am I getting this jittering when my player collides with corners at the top and bottom (and not the left and right)?

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

Hi there, I’m working on a game (built on top of of one of the isometric samples in Godot) and I’m making slow and steady progress.

However, I’m encountering an issue where everything jitters when the player (KinematicBody2D) collides with certain corners in my tilemap. Specifically, if my character walks straight up into a corner above him, the jittering occurs. Same thing if he walks straight down into a corner below.

It doesn’t happen if the player moves left or right into corners. Here’s a video showing what happens: Imgur: The magic of the Internet

I’m calling the move_and_slide function inside of the _physics_process function of the player KinematicBody2D object. Anyone have any idea of what’s going on and what I might be able to do to fix this?


Could you show the relevant code in your process function please?

DaddyMonster | 2021-12-07 00:25


This is my code:

var motion = Vector2()

motion.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")

motion.y = Input.get_action_strength("move_down") - Input.get_action_strength("move_up")

motion.y /= 2

motion = motion.normalized() * MOTION_SPEED

move_and_slide(motion, Vector2.UP, false, 4, PI/4, false)

unicornsoftwareinc | 2021-12-08 20:57

:bust_in_silhouette: Reply From: DaddyMonster

Hmm… That doesn’t help. Those vectors are definitely fine. Yeah, code is fine. Not sure why you changed infinite_inertia to false but it shouldn’t make a difference. I guess that was during debuging.

Ok, go to the debug menu and choose “visible collision shapes” - this will let you see the collision shapes in runtime, in case there’s a weird protrusion of something. Check for overlapping. Iso isn’t x to y symmetrical, there’s twice the angle up than there is across.

Try printing the collisions (with get_slide_count() and get_slide_collision()). Maybe they have weird normals or something.

Make sure that the walls aren’t colliding with themselves. Check the mask/layers.

If the collision shape is a box, try it with a circle and see.

You can tweek collision settings but I’m reluctant to tell you to do that, the default is generally fine.

Oh! Check the camera. Make sure that isn’t the cause / no snapping / no limits / no floor / round / etc.

Sorry I wasn’t more help buddy, I’m genuinely not sure.