This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Hi, I made an arrowUp scene and a timer to spawn. If I press "ui_up" button it's deleting all the objects that has been added to a world.tscn. What I wanna do is delete one arrowUp scene not all the arrowUp instanced scenes.


var arrowUpScene = preload("res://Scenes/ArrowUp.tscn")

func spawnArrowUp():
    var arrowUp = arrowUpScene.instance()
    arrowUp.speed = randi() % 270 + 990
    arrowUp.global_position = Vector2(hotSpot.position.x + 800, hotSpot.position.y - 15)

func _on_spawnTimer_timeout():
timer.wait_time = rand_range(1, 2)


extends Area2D

onready var anim_p = $AnimationPlayer

var speed = 270
var pressed = false

func _physics_process(_delta):
    if !pressed:
        position.x -= speed * _delta

    if Input.is_action_just_pressed("ui_up"):
        if Global.arrowUpOnHotspot:
            pressed = true
            pressed = true

func _on_ArrowUp_area_entered(area):
    if area.is_in_group("listener"):
        Global.arrowUpOnHotspot = true

func _on_ArrowUp_area_exited(area):
    if area.is_in_group("listener"):
        Global.arrowUpOnHotspot = false

func _on_AnimationPlayer_animation_finished(anim_name):
    if anim_name == "success":
    if anim_name == "fail":


Godot version latest
in Engine by (15 points)

1 Answer

+1 vote
Best answer

I think the problem is that you are using a global variable as a condition. When you use Global.arrowUpOnHotspot = true you are modifying that variable for all instances that use it. One way to fix this is to create a local variable in the ArrowUp script to use as a condition.

by (2,260 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.