Godot Version
extends CharacterBody2D
@onready var left = $Left
@onready var right = $Right
@onready var down = $Down
@onready var up = $Up
@onready var node = $“…”
@onready var bf_act_1 = $“…/BF Act 1”
var player
Called when the node enters the scene tree for the first time.
func _ready():
var player = bf_act_1
Called every frame. ‘delta’ is the elapsed time since the previous frame.
func _process(delta):
if left.has_overlapping_bodies() and Input.is_action_just_pressed(“Left”):
var body = left.get_overlapping_bodies().find(0)
var ToDestroy = node.get_child(body)
ToDestroy.queue_free()
bf_act_1.animation = “Left”
if down.has_overlapping_bodies() and Input.is_action_just_pressed("Down"):
var body1 = down.get_overlapping_bodies().find(0)
var ToDestroy = node.get_child(body1)
ToDestroy.queue_free()
bf_act_1.animation = "Down"
if right.has_overlapping_bodies() and Input.is_action_just_pressed("Right"):
var body2 = right.get_overlapping_bodies().find(0)
var ToDestroy = node.get_child(body2)
ToDestroy.queue_free()
bf_act_1.animation = "Right"
if up.has_overlapping_bodies() and Input.is_action_just_pressed("Up"):
var body3 = up.get_overlapping_bodies().find(0)
var ToDestroy = node.get_child(body3)
ToDestroy.queue_free()
bf_act_1.animation = "Up"
func _on_bf_act_1_animation_looped():
bf_act_1.animation = “Idle”
Question
`So basically in this code the object when i click the object in the lane is meant to be destroyed but for some reason it destroys the ones in alternate lanes(This is for a rythym game for clarification)