Hey Im lerning Godot 4.4 so i reactring a Super Mario Bros from the NES soo i was doing the enemy but for some reson this pal continus detect the colision and he just vibring and I put a CoolDown for that but insted he still doing the same thing, I change everything so many times and I just comeback to de " StableCode" can someone give some help or else give another way to recreate de code of the Goomba?. PLS
CODE enemy:
extends CharacterBody2D
const speed = 80
const gravity = 1000
var facing_right = true #detecta enemy derecha
Movimiento del enemigo
func _physics_process(delta): #función especial se ejecuta cada fotograma física
if facing_right: #si se cumple la condicion
velocity.x = speed * 1 # en los vectores si es 1 va hacia la derecha
else:# no se cumple la condición
velocity.x = speed * -1 # si es -1 hacia la izquierda
if not is_on_floor():# si no esta en el suelo pasa:
velocity.y += gravity * delta
else:
velocity.y = 0 #impide que el enemigo se siga “hundiendo” en el piso.
move_and_slide()
# GSCC es un metodo nativo de Godot
for i in get_slide_collision_count(): # for = bucle/i var almacenar conteo
var colision = get_slide_collision(i)# C almacena con el metodoGSC las C i
var normal = colision.get_normal()#Guarda Cantidad registro C
# Si la colisión fue lateral (izquierda o derecha), cambia la dirección
if normal.x != 0:
facing_right = not facing_right
print("toca") # obvio
break