2023-09-30 18:16:14 +00:00
|
|
|
extends Node2D
|
|
|
|
class_name Spawner
|
2023-09-30 23:33:54 +00:00
|
|
|
|
|
|
|
|
2023-09-30 18:16:14 +00:00
|
|
|
@export var scene: PackedScene
|
2023-09-30 23:33:54 +00:00
|
|
|
|
2023-09-30 18:16:14 +00:00
|
|
|
|
|
|
|
func spawn():
|
2023-09-30 23:33:54 +00:00
|
|
|
var overlapping_bodies = $Area.get_overlapping_bodies()
|
|
|
|
for overlapping_body in overlapping_bodies:
|
|
|
|
if overlapping_body.collision_layer && 0b100:
|
|
|
|
print("[Spawner] Not spawning, overlapping with: ", overlapping_body)
|
|
|
|
return
|
|
|
|
|
2023-09-30 21:13:55 +00:00
|
|
|
var scene_instant = scene.instantiate()
|
2023-09-30 23:33:54 +00:00
|
|
|
scene_instant.position = Vector2.ZERO
|
|
|
|
print("[Spawner] Created: ", scene_instant)
|
2023-09-30 18:16:14 +00:00
|
|
|
add_child(scene_instant)
|