Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | mmntry |
Hi,
I dont really know how to put it, so I hope you understand what I mean.
While moving or jumping there is a “half pixel gap” between the kinematicbody2d and the tile map.
Here’s a gif to properly show what I’m talking about.
This is the players movement script:
func move():
var useFriction = false
# movement
if Input.is_action_pressed("ui_left"):
$AnimatedSprite.set_flip_h(true) # flip sprite to face into correct direction
motion.x -= ACCELERATION; # add acceleration to move to left
motion.x = max(motion.x, -MAX_SPEED) # use motion.x only if its smaller than the max speed
elif Input.is_action_pressed("ui_right"):
$AnimatedSprite.set_flip_h(false) # flip sprite to face into correct direction
motion.x += ACCELERATION
motion.x = min(motion.x, MAX_SPEED)
else:
$AnimatedSprite.play("idle")
useFriction = true
# jump
if is_on_floor():
if Input.is_action_just_pressed("ui_up"):
motion.y = JUMP_HEIGHT
jumpSound = get_node("jumpy")
jumpSound.play()
else:
$AnimatedSprite.play("idle")
if useFriction == true:
motion.x = lerp(motion.x, 0, FRICTION_GROUND)
else:
$AnimatedSprite.play("fall")
if useFriction == true:
motion.x = lerp(motion.x, 0, FRICTION_AIR) # the friction in the air should be less than on the ground
The player sprite is 14x26 px and the game size is 480x270.
Thanks in advance!
hi, did you fixed it? i have same problem
boruok | 2019-11-12 06:05