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

👩🏻‍🔧 Add check to only shoot peas on free slots

This commit is contained in:
Ichicoro 2023-01-08 14:48:15 +01:00
parent a9a0c76cd6
commit 56993e3d1d
5 changed files with 11 additions and 4 deletions

View file

@ -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)

View file

@ -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")

View file

@ -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")

View file

@ -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

View file

@ -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