1
Fork 0
mirror of https://github.com/Steffo99/pineapple-surf.git synced 2024-11-21 23:34:21 +00:00

Fix various bugs related to planting seeds

This commit is contained in:
Steffo 2023-01-09 00:28:39 +01:00
parent 37c019f776
commit fc286266d7
Signed by: steffo
GPG key ID: 6965406171929D01
7 changed files with 18 additions and 8 deletions

View file

@ -10,6 +10,7 @@ signal on_complete()
@onready var sprout_mesh: MeshInstance3D = $Plant/Sprout @onready var sprout_mesh: MeshInstance3D = $Plant/Sprout
@onready var pop_sound: AudioStreamPlayer3D = $Pop @onready var pop_sound: AudioStreamPlayer3D = $Pop
@onready var producer: Node3D = $Producer @onready var producer: Node3D = $Producer
@onready var plant_shape: CollisionShape3D = $Plant/PlantableArea
@export var produce_scene: PackedScene = preload("res://island/Pineapple.tscn") @export var produce_scene: PackedScene = preload("res://island/Pineapple.tscn")
@ -29,6 +30,10 @@ func complete():
emit_signal("on_complete") emit_signal("on_complete")
if debug_growth: if debug_growth:
plant() plant()
else:
plant_shape.disabled = true
await get_tree().create_timer(1).timeout
queue_free()
func _process(_delta): func _process(_delta):

View file

@ -6,10 +6,10 @@
[ext_resource type="AudioStream" uid="uid://lkftwgdun745" path="res://assets/pop.wav" id="3_gur2a"] [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"] [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) size = Vector3(1, 0.1, 1)
[sub_resource type="ArrayMesh" id="ArrayMesh_b2165"] [sub_resource type="ArrayMesh" id="ArrayMesh_i27yi"]
_surfaces = [{ _surfaces = [{
"aabb": AABB(-0.5, 0, -0.5, 1.00001, 1.00001, 1), "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), "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"] [node name="PlantableArea" type="CollisionShape3D" parent="Plant"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.05, 0) 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"] [node name="Sprout" type="MeshInstance3D" parent="Plant"]
transform = Transform3D(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) transform = Transform3D(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
mesh = SubResource("ArrayMesh_b2165") mesh = SubResource("ArrayMesh_i27yi")
skeleton = NodePath("../../..") skeleton = NodePath("../../..")
[node name="GrowthTimer" type="Timer" parent="."] [node name="GrowthTimer" type="Timer" parent="."]

View file

@ -25,6 +25,7 @@ mesh = SubResource("ArrayMesh_f0lr0")
skeleton = NodePath("../..") skeleton = NodePath("../..")
[node name="StaticBody3D" type="StaticBody3D" parent="."] [node name="StaticBody3D" type="StaticBody3D" parent="."]
collision_layer = 9
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"] [node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
shape = SubResource("ConcavePolygonShape3D_psqce") shape = SubResource("ConcavePolygonShape3D_psqce")

1
island/Pineapple.gd Normal file
View file

@ -0,0 +1 @@
extends RigidBody3D

View file

@ -25,6 +25,7 @@ mesh = SubResource("ArrayMesh_ukixy")
skeleton = NodePath("../..") skeleton = NodePath("../..")
[node name="StaticBody3D" type="StaticBody3D" parent="."] [node name="StaticBody3D" type="StaticBody3D" parent="."]
collision_layer = 9
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"] [node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
shape = SubResource("ConcavePolygonShape3D_emoh5") shape = SubResource("ConcavePolygonShape3D_emoh5")

View file

@ -25,6 +25,7 @@ mesh = SubResource("ArrayMesh_0ltt5")
skeleton = NodePath("../..") skeleton = NodePath("../..")
[node name="StaticBody3D" type="StaticBody3D" parent="."] [node name="StaticBody3D" type="StaticBody3D" parent="."]
collision_layer = 9
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"] [node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
shape = SubResource("ConcavePolygonShape3D_lnxpp") shape = SubResource("ConcavePolygonShape3D_lnxpp")

View file

@ -56,15 +56,16 @@ func try_placing_seed(ray: RayCast3D) -> bool:
var point = ray.get_collision_point() as Vector3 var point = ray.get_collision_point() as Vector3
var normal = ray.get_collision_normal() as Vector3 var normal = ray.get_collision_normal() as Vector3
var coll = ray.get_collider() as CollisionObject3D var coll = ray.get_collider() as CollisionObject3D
if normal != Vector3(0,1,0): var similarity = normal.dot(Vector3.UP)
print("Not horizontal, no plant for you :<")
if similarity < 0.95:
return false return false
if coll.collision_layer == 0b10000: if coll.collision_layer == 0b10000:
print("Colliding with planted seed, not planting again")
return false 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 var crop = croptile.instantiate() as CropTile
crop.position = correct_point crop.position = correct_point
croptiles_container.add_child(crop) croptiles_container.add_child(crop)