You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
``When I move my 2D character to any corner shape it jitters.
My player is: a KinematicBody2D with a Sprite and a CollisionShape2D (it happens in any shape: rectangle, capsule, circle, ...).
My player has a script attached.
The walls are: a StaticBody2D with a CollisionPolygon2D.
Godot_v3.2022-08-20.16-35-11-47.mp4
extends KinematicBody2D
var vel = Vector2.ZERO
const MAX_SPD = 80
func _physics_process(delta):
var input_vector = Vector2.ZERO
input_vector.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
input_vector.y = Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
input_vector = input_vector.normalized()
vel = input_vector * MAX_SPD
vel = move_and_slide(vel)
This is likely an issue with your code, rather than the physics engine. In other words, your player is "flip-flopping" endlessly between two walls due to the instant acceleration and lack of friction.
Try ignoring movement if it's smaller than a certain amount, or implement some kind of movement acceleration/friction.
I knew with acceleration it can be "fixed" (not really fixed but making the jittering so little that the screen can't show it), but I'd rather have a solution which implied pushing the character to the right place (right above the corner) instead of some units in the above
My understanding is that when you slide in those corners you always end up entering one wall then pushed away into the other wall. This is why it jitters. If this is the actual reason, there is no bug here.
Do you want an easy way of "fixing" this jitter? Instead of move_and_slide with default parameters, decrease max_slides to 2:
vel=move_and_slide(vel, Vector2.ZERO, false, 2)
This will likely have negative consequences if your game has moving platforms and other KinematicBody interactions, but it does stop this specific jittering.
Godot version
v3.4.4-stable_win64
System information
Windows 10, i5-9600K, RTX 2060, 16GB RAM, GLES3
Issue description
``When I move my 2D character to any corner shape it jitters.
My player is: a KinematicBody2D with a Sprite and a CollisionShape2D (it happens in any shape: rectangle, capsule, circle, ...).
My player has a script attached.
The walls are: a StaticBody2D with a CollisionPolygon2D.
Godot_v3.2022-08-20.16-35-11-47.mp4
The prints on the wall:
"before(-80, 0)
after(6.303683, 7.879045)
Falsefloor
Truewall
before(-80, 0)
after(6.29903, -31.520666)
Falsefloor
Truewall
before(-80, 0)
after(-3.076349, 15.385308)
Falsefloor
Truewall"
etc
The prints on the floor:
"before(0, 80)
after(28.24184, -7.050445)
Falsefloor
Truewall
before(0, 80)
after(-18.827187, 4.720105)
Falsefloor
Truewall
before(0, 80)
after(-7.062556, -7.058139)
Falsefloor
Truewall"
etc
This bug only happens with a corner, but not a single wall
Steps to reproduce
Make the same scene as I did with the same script, and just collide with a corner-like (not a wall but 2 walls making a corner!)
Minimal reproduction project
p2.zip
The text was updated successfully, but these errors were encountered: