diff --git a/island/CropTile.gd b/island/CropTile.gd index 68f9318..d8ab9d3 100644 --- a/island/CropTile.gd +++ b/island/CropTile.gd @@ -10,6 +10,7 @@ signal on_complete() @onready var sprout_mesh: MeshInstance3D = $Plant/Sprout @onready var pop_sound: AudioStreamPlayer3D = $Pop @onready var producer: Node3D = $Producer +@onready var plant_shape: CollisionShape3D = $Plant/PlantableArea @export var produce_scene: PackedScene = preload("res://island/Pineapple.tscn") @@ -29,6 +30,10 @@ func complete(): emit_signal("on_complete") if debug_growth: plant() + else: + plant_shape.disabled = true + await get_tree().create_timer(1).timeout + queue_free() func _process(_delta): diff --git a/island/CropTile.tscn b/island/CropTile.tscn index 90178a8..c6f2440 100644 --- a/island/CropTile.tscn +++ b/island/CropTile.tscn @@ -6,10 +6,10 @@ [ext_resource type="AudioStream" uid="uid://lkftwgdun745" path="res://assets/pop.wav" id="3_gur2a"] [ext_resource type="Script" path="res://island/Pop.gd" id="4_5e7wk"] -[sub_resource type="BoxShape3D" id="BoxShape3D_flxvl"] +[sub_resource type="BoxShape3D" id="BoxShape3D_370jp"] size = Vector3(1, 0.1, 1) -[sub_resource type="ArrayMesh" id="ArrayMesh_b2165"] +[sub_resource type="ArrayMesh" id="ArrayMesh_i27yi"] _surfaces = [{ "aabb": AABB(-0.5, 0, -0.5, 1.00001, 1.00001, 1), "attribute_data": PackedByteArray(143, 194, 117, 63, 183, 109, 91, 63, 31, 133, 107, 63, 219, 182, 109, 63, 31, 133, 107, 63, 183, 109, 91, 63, 143, 194, 117, 63, 219, 182, 109, 63, 143, 194, 117, 63, 183, 109, 91, 63, 31, 133, 107, 63, 183, 109, 91, 63, 31, 133, 107, 63, 219, 182, 109, 63, 143, 194, 117, 63, 219, 182, 109, 63, 143, 194, 117, 63, 183, 109, 91, 63, 31, 133, 107, 63, 183, 109, 91, 63, 31, 133, 107, 63, 219, 182, 109, 63, 143, 194, 117, 63, 219, 182, 109, 63, 143, 194, 117, 63, 183, 109, 91, 63, 31, 133, 107, 63, 183, 109, 91, 63, 31, 133, 107, 63, 219, 182, 109, 63, 143, 194, 117, 63, 219, 182, 109, 63), @@ -37,11 +37,11 @@ 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) -shape = SubResource("BoxShape3D_flxvl") +shape = SubResource("BoxShape3D_370jp") [node name="Sprout" type="MeshInstance3D" parent="Plant"] transform = Transform3D(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) -mesh = SubResource("ArrayMesh_b2165") +mesh = SubResource("ArrayMesh_i27yi") skeleton = NodePath("../../..") [node name="GrowthTimer" type="Timer" parent="."] diff --git a/island/HoppityMesh.tscn b/island/HoppityMesh.tscn index 795bc2a..b1bf6cd 100644 --- a/island/HoppityMesh.tscn +++ b/island/HoppityMesh.tscn @@ -25,6 +25,7 @@ mesh = SubResource("ArrayMesh_f0lr0") skeleton = NodePath("../..") [node name="StaticBody3D" type="StaticBody3D" parent="."] +collision_layer = 9 [node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"] shape = SubResource("ConcavePolygonShape3D_psqce") diff --git a/island/Pineapple.gd b/island/Pineapple.gd new file mode 100644 index 0000000..0c5c0bb --- /dev/null +++ b/island/Pineapple.gd @@ -0,0 +1 @@ +extends RigidBody3D diff --git a/island/PyramidSmallMesh.tscn b/island/PyramidSmallMesh.tscn index 03b7a89..b9ec343 100644 --- a/island/PyramidSmallMesh.tscn +++ b/island/PyramidSmallMesh.tscn @@ -25,6 +25,7 @@ mesh = SubResource("ArrayMesh_ukixy") skeleton = NodePath("../..") [node name="StaticBody3D" type="StaticBody3D" parent="."] +collision_layer = 9 [node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"] shape = SubResource("ConcavePolygonShape3D_emoh5") diff --git a/island/PyramidSmolMesh.tscn b/island/PyramidSmolMesh.tscn index c7c8be8..56dc1c2 100644 --- a/island/PyramidSmolMesh.tscn +++ b/island/PyramidSmolMesh.tscn @@ -25,6 +25,7 @@ mesh = SubResource("ArrayMesh_0ltt5") skeleton = NodePath("../..") [node name="StaticBody3D" type="StaticBody3D" parent="."] +collision_layer = 9 [node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"] shape = SubResource("ConcavePolygonShape3D_lnxpp") diff --git a/player/onhand/PeaShooter.gd b/player/onhand/PeaShooter.gd index e09b1d4..60b05d1 100644 --- a/player/onhand/PeaShooter.gd +++ b/player/onhand/PeaShooter.gd @@ -56,15 +56,16 @@ func try_placing_seed(ray: RayCast3D) -> bool: var point = ray.get_collision_point() as Vector3 var normal = ray.get_collision_normal() as Vector3 var coll = ray.get_collider() as CollisionObject3D - if normal != Vector3(0,1,0): - print("Not horizontal, no plant for you :<") + var similarity = normal.dot(Vector3.UP) + + if similarity < 0.95: return false if coll.collision_layer == 0b10000: - print("Colliding with planted seed, not planting again") return false - var correct_point = point.floor() + var correct_point = Vector3(floor(point.x), round(point.y), floor(point.z)) + var crop = croptile.instantiate() as CropTile crop.position = correct_point croptiles_container.add_child(crop)