well, i want to detect when there is a precipice to change de direction of the NPC so it doesn't fall, i have this but it doesn't work, i reed something about the test move but i donk can implement well yet so i use the isonfloor:
extends KinematicBody2D
const suelo = Vector2(0, -1);
const GRAVITY = 20;
const walk_speed = 75;
var movement = Vector2();
var left = Vector2(-1, 0);
var right = Vector2(1, 0);
var direction = right;
func _physics_process(_delta):
movement.y += GRAVITY;
movement.x = direction.x * walk_speed;
movement = move_and_slide(movement, suelo);
#comprobamos cuando chaca con una pared para continuar el movimiento en direccion
#contraria
if is_on_wall():
if direction == left:
direction = right;
elif direction == right:
direction = left;
#ahora le damos la deteccion de caida, donde no hay suelo
if self.is_on_floor():
print("on floor");
elif direction == right:
direction = right
else:
direction = left