Ive tried all the solutions on this forum but none helped at all isonfloor always says false.
heres my player script
const UP = Vector2(0, -1)
var velocity = Vector2()
var moveSpeed = 500
var friction = 0.2
var gravity = 1200
var jumpVelocity = -720
func _ready():
pass # Replace with function body.
func _physics_process (delta):
move_and_slide_with_snap(velocity, Vector2.UP, UP)
if is_on_floor():
velocity.y = gravity
else:
velocity.y += gravity * delta
_get_input()
func _input(event):
if event.get_action_strength("jump") && is_on_floor():
velocity.y += jumpVelocity
func _get_input():
var moveDirection = -int(Input.get_action_strength("left")) + int(Input.get_action_strength("right"))
velocity.x = lerp(velocity.x, moveSpeed * moveDirection, friction)