Attention | Topic was automatically imported from the old Question2Answer platform. | |
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.