1
Fork 0
mirror of https://github.com/Steffo99/swear-jar.git synced 2024-11-28 18:34:18 +00:00
swear-jar/spawner/spawner.gd

19 lines
469 B
GDScript3
Raw Normal View History

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
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)