1
Fork 0
mirror of https://github.com/Steffo99/swear-jar.git synced 2024-11-25 00:54:19 +00:00

Prevent spawn if coins would overlap

This commit is contained in:
Steffo 2023-10-01 00:05:15 +02:00
parent 42c2344ec0
commit 0f51e2e8d6
Signed by: steffo
GPG key ID: 2A24051445686895
2 changed files with 7 additions and 7 deletions

View file

@ -4,7 +4,7 @@ class_name Spawner
@export var target_parent: NodePath
func spawn():
if len($Area2D.get_overlapping_bodies()) > 0:
if len($Area.get_overlapping_bodies()) > 0:
return
var scene_instant = scene.instantiate()
scene_instant.position=Vector2.ZERO

View file

@ -2,8 +2,8 @@
[ext_resource type="Script" path="res://spawner/spawner.gd" id="1_xqfmg"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_xnebx"]
size = Vector2(100, 20)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_p13i4"]
size = Vector2(16, 5)
[node name="Spawner" type="Node2D"]
script = ExtResource("1_xqfmg")
@ -12,11 +12,11 @@ script = ExtResource("1_xqfmg")
wait_time = 0.1
autostart = true
[node name="Area2D" type="Area2D" parent="."]
[node name="Area" type="Area2D" parent="."]
collision_mask = 4
[node name="Shape" type="CollisionShape2D" parent="Area2D"]
position = Vector2(0, -15)
shape = SubResource("RectangleShape2D_xnebx")
[node name="CoinShape" type="CollisionShape2D" parent="Area"]
scale = Vector2(3, 3)
shape = SubResource("RectangleShape2D_p13i4")
[connection signal="timeout" from="Timer" to="." method="spawn"]