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:
parent
37c019f776
commit
fc286266d7
7 changed files with 18 additions and 8 deletions
|
@ -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):
|
||||
|
|
|
@ -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="."]
|
||||
|
|
|
@ -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")
|
||||
|
|
1
island/Pineapple.gd
Normal file
1
island/Pineapple.gd
Normal file
|
@ -0,0 +1 @@
|
|||
extends RigidBody3D
|
|
@ -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")
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue