Problems with the is_on_floor() function.

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

So here comes what seems to be a relatively common question, but I still don’t quite understand. I have a level with a character and blocks that both have collision shapes.
Why does the terminal still say that is_on_floor() == false? Below is the code I feel is relevant to the question and thanks in advance.


extends KinematicBody2D

Declare member variables here

var velocity = Vector2()
var velocity_jump = Vector2()

export(int) var speed = 200

export var jump_height : float = 100
export var jump_time_peak : float = 0.5
export var jump_time_to_descent : float = 0.4

onready var jump_velocity : float = ((2.0 * jump_height) / jump_time_peak) * -1.0
onready var jump_gravity : float = ((-2.0 * jump_height) / pow( jump_time_peak, 2)) * -1.0
onready var fall_gravity : float = ((-2.0 * jump_height) / pow( jump_time_to_descent, 2)) * -1.0

#Physics calc
func _physics_process(_delta):
velocity_jump.y += get_gravity() * _delta
velocity_jump.x = get_input_velocity_x() * speed

if Input.is_action_just_pressed("move_up"):
	print("jumping",$".".is_on_floor())
	_jump()

if get_tree().is_network_server() and is_left:
	velocity_jump = move_and_slide(velocity_jump, Vector2.UP)

if !get_tree().is_network_server() and !is_left:
	velocity_jump = move_and_slide(velocity_jump, Vector2.UP)

#rpc("up_pos",$".".position)

func get_gravity() → float:
return jump_gravity if velocity.y < 0.0 else fall_gravity

func _process(_delta):

velocity = Vector2()
 # The player's movement vector.
if Input.is_action_pressed("move_left"):
	velocity.x -= 1
if Input.is_action_pressed("move_right"):
	velocity.x += 1

#Move set
func _ready():
t.x = 450
t.y = 250
$“.”.position = t

func _attack1():
pass

func _attack2():
pass

func _dodge():
pass

func _jump():
velocity_jump.y = jump_velocity