I am making a sidescrolling shooter and I am working on the shooting mechanism. I have two scenes, one contains a KinematicBody2D with a Sprite, position2D and a collisionshape2D and a second KinematicBody2D with a CollisionShape for testing bullet collision. The scene also has a Tilemap called Level. In the second scene I have an Area2D with sprite and collisionshape as my bullet.
Code for the bullet (Only important parts):
extends Area2D onready var sprite = get_node("/root/Game/Player/Sprite") func _on_VisibilityNotifier2D_screen_exited(): print("Freed") queue_free() func _on_Bullet_body_entered(body): print("Entered: ", body.name)
Player shoot() function:
func shoot(): var bullet = Bullet.instance() get_node("/root/Game").add_child(bullet) bullet.global_position = $Position2D.global_position
Upon starting the game this is printed out, without the player having shot:
Entered: Player Entered: Level Freed
When shooting into the second KinematicBody2D, nothing happens at all, the bullet only gets freed after exiting the screen.
What am I doing wrong?