From 56993e3d1d31e6712c6b1094340aa3441ec24e5c Mon Sep 17 00:00:00 2001 From: Ichicoro Date: Sun, 8 Jan 2023 14:48:15 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=A9=F0=9F=8F=BB=E2=80=8D=F0=9F=94=A7?= =?UTF-8?q?=20Add=20check=20to=20only=20shoot=20peas=20on=20free=20slots?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- island/CropTile.tscn | 4 ++-- island/HillMesh.tscn | 1 + island/IslandMesh.tscn | 1 + player/onhand/PeaShooter.gd | 7 +++++-- player/onhand/PeaShooter.tscn | 2 ++ 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/island/CropTile.tscn b/island/CropTile.tscn index 0a7d3d3..a897414 100644 --- a/island/CropTile.tscn +++ b/island/CropTile.tscn @@ -32,8 +32,8 @@ script = ExtResource("2_jejoo") [node name="Plant" type="Area3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 0, 0.5) -collision_layer = 0 -collision_mask = 16 +collision_layer = 16 +collision_mask = 0 [node name="PlantableArea" type="CollisionShape3D" parent="Plant"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.05, 0) diff --git a/island/HillMesh.tscn b/island/HillMesh.tscn index 960d3f5..050096c 100644 --- a/island/HillMesh.tscn +++ b/island/HillMesh.tscn @@ -25,6 +25,7 @@ mesh = SubResource("ArrayMesh_s0thi") skeleton = NodePath("../..") [node name="StaticBody3D" type="StaticBody3D" parent="."] +collision_layer = 9 [node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"] shape = SubResource("ConcavePolygonShape3D_0ox82") diff --git a/island/IslandMesh.tscn b/island/IslandMesh.tscn index 5af12af..13f8af9 100644 --- a/island/IslandMesh.tscn +++ b/island/IslandMesh.tscn @@ -24,6 +24,7 @@ mesh = SubResource("ArrayMesh_nmvk4") skeleton = NodePath("../..") [node name="StaticBody3D" type="StaticBody3D" parent="."] +collision_layer = 9 [node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"] shape = SubResource("ConcavePolygonShape3D_o3dws") diff --git a/player/onhand/PeaShooter.gd b/player/onhand/PeaShooter.gd index 7523d67..1b14dab 100644 --- a/player/onhand/PeaShooter.gd +++ b/player/onhand/PeaShooter.gd @@ -53,11 +53,14 @@ func shoot() -> void: func try_placing_seed(ray: RayCast3D) -> bool: var point = ray.get_collision_point() as Vector3 var normal = ray.get_collision_normal() as Vector3 - var obj = ray.get_collider() as Node3D - print(point, normal, obj.name) + var coll = ray.get_collider() as CollisionObject3D if normal != Vector3(0,1,0): print("Not horizontal, no plant for you :<") return false + + if coll.collision_layer == 0b10000: + print("Colliding with planted seed, not planting again") + return false var correct_point = point.floor() var crop = croptile.instantiate() as CropTile diff --git a/player/onhand/PeaShooter.tscn b/player/onhand/PeaShooter.tscn index dffda64..547e03e 100644 --- a/player/onhand/PeaShooter.tscn +++ b/player/onhand/PeaShooter.tscn @@ -8,3 +8,5 @@ script = ExtResource("1_bl35a") [node name="RayCast3D" type="RayCast3D" parent="."] target_position = Vector3(1000, 0, 0) +collision_mask = 24 +collide_with_areas = true