Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Guiguis_Galdis |
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()
I cannot see anything wrong with your code! Can you provide an example project?
njamster | 2020-06-14 17:47