0 votes

Hello, I programmed a bullet that disappears when hitting a door, but it only works with the second bullet and so on, why not with the first shot?

Here is my code:

extends Sprite

onready var player = get_tree().get_root().get_node("World/Player")
var velocity = Vector2()

func _ready():
    $Area2D.connect("body_entered", self, "on_Area2D_entered")

func _process(delta):
    move(delta)

func move(delta):
    global_position += velocity * delta

func on_Area2D_entered(body):
    if body.name == "Player":
        player.alive = false
        queue_free()
    elif body.is_in_group("doors"):
        queue_free()
in Engine by (24 points)

I cannot see anything wrong with your code! Can you provide an example project?

Please log in or register to answer this question.

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 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 webmaster@godotengine.org with your username.