![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Seph |
Here is my code:
extends KinematicBody2D
func _ready():
pass
# Default (0, 600)
const GRAVITY = Vector2(0, 600)
# Default (0, -1)
const FLOOR_NORMAL = Vector2(0, -1)
# Default 60
const SLOPE_FRICTION = 60
# Max movement speed, Default 300
const MOVEMENT_SPEED = 300
# Default 0.2
const ACCELERATION = 0.2
# Velocity
var velocity = Vector2()
# Used for horizontal movement
var movement = 0
func _physics_process(delta):
# Beginning of all movement
velocity = move_and_slide(velocity, FLOOR_NORMAL, SLOPE_FRICTION)
# Resets movement
movement = 0
# Left & Right Movement
# Adjust the movement in order to see how bad the jitter is
# Movement is A and D, Left or Right arrow keys, or Gamepad left & right
# Movement - Left
if Input.is_action_pressed("left"):
movement -= 25
# Movement - Right
if Input.is_action_pressed("right"):
movement += 25
# Finalize Movement (NO MORE CHANGES TO MOVEMENT FROM HERE)
movement *= MOVEMENT_SPEED
# Linear Interpolation, used for acceleration towards a point
velocity.x = lerp(velocity.x, movement, ACCELERATION)
The only objects in my scene are the Kinematic body, the sprite attached to it, and a camera attached to it set as current with smoothing enabled at a value of ‘20’. That’s all.
This problem pretty much breaks my platformer, so I can’t really do anything more from here. I’m completely stumped.
This code works perfectly fine in Godot v2.2, so I am unsure what the problem is. Any help would be appreciated. If more information is needed, I can provide the project and/or pictures.
Edit:
Here is a video demonstrating my problem:
Nothing catches my attention as source of problem. So if you can provide something to reproduce problem (scene/project) . Some picture would also be helpful.
Bartosz | 2018-03-29 22:31
is your camera moving? with smooth enabled? project settings with vsync enabled? and pixel snap enabled?
eons | 2018-03-30 00:52
My camera is moving, yes. Smooth is enabled with a value of ‘20’. Vsync is disabled. I am unsure where pixel snap is, so whatever the default setting is.
I am also unsure of what the best way to share my project is, sorry. Could I get a recommendation to make this easier for you guys?
Seph | 2018-03-30 01:25
If you turn off camera smoothing does the jittering persist? Any way you can embed a GIF of the jittering?
Diet Estus | 2018-03-30 04:40
Here is a link to a video showing my problem:
https://www.youtube.com/watch?v=ga7WUEIBJG8&feature=youtu.be
Turning off the camera smoothing makes the jittering go away a bit, but not all the way. I think the problem lies in move_and_slide(), but I’m not exactly sure.
Seph | 2018-03-30 06:54
I struggle with the same issue in my project. I get the same jittering as you when my sprite is free falling and reaches the bottom of the viewport. I, however, don’t notice the jittering when smoothing is disabled. I am going to experiment with writing some custom camera code, as mentioned by girng here and eons below. If I find something that works I will update my answer. This problem really needs a definitive write-up since I feel like a lot of users struggle with it.
Diet Estus | 2018-03-30 20:06
Okay, so I have done a bit of testing with camera smoothing off and the problem still persists. A lot. I made a video showing it:
https://www.youtube.com/watch?v=UnUPCiF3K98
This is a pretty terrible bug, I hope it gets fixed soon.
Seph | 2018-03-31 18:02