Godot Version
4.6.2
Question
i’m using a character 2d node to make a bullet type of entity, this is the code i’m using (excluding variable declarations), but for some reason when direction is 0 it works just fine, same thing when it’s -1 but when it’s 1 it justs becomes invisible
func despawn():
if dead == false:
animated_sprite_2d.play("splash")
dead = true
if animated_sprite_2d.is_playing():
return
queue_free()
func _physics_process(delta: float) -> void:
if not is_on_floor():
velocity += get_gravity() * delta * 1.5
#sistema right
if direction >= 0:
if not ray_r.is_colliding():
velocity.x = Speed * delta * 1
else:
despawn()
#left
elif direction < 0:
if not ray_l.is_colliding():
velocity.x = Speed * delta * -1
else:
despawn()