falling and colliding with floor issue

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

hello everyone i have a weird issue when my player is falling and is about to collide with the floor sometimes it stops just before colliding, i had some colliders with scaling but i fixed all of them and it still happens.

this video shows the problem: https://youtu.be/TQUBL-a6CHw

and this is my code for jumping:

extends KinematicBody


const SPEED =100
var velocity=Vector3()
const JUMP_VEL=2
const gravity=-9.8

func _ready():

set_physics_process(true)



func _physics_process(delta):
	var dir = Vector3()




dir.y = 0

dir = dir.normalized()


velocity.y += delta * gravity



var hv = velocity

hv.y = 0


var new_pos = dir * SPEED


hv = new_pos*delta


velocity.x = hv.x

velocity.z = hv.z



if (is_on_floor()):
    velocity.y=0    

# -------------------SALTO-------------------

if (Input.is_action_just_pressed('jump')):



    velocity.y = JUMP_VEL




# ---------------Movimiento -----------------

velocity = move_and_slide(velocity, Vector3(0,1,0),0.05)

i can upload a demo project if its needed.
thx in advance.

:bust_in_silhouette: Reply From: arthurZ

Have you tried using raycasts to check the ground? Sometimes it is a better solution than using is_on_floor ().

what i could understand the issue is related to move and slide the third argument takes a float, default is 0.05 i think, if i change it to 0 it stops that weird behavior but i cant have platforms in angles because the player never stops

torohaifisch | 2019-01-29 08:01