1
Fork 0
mirror of https://github.com/Steffo99/pineapple-surf.git synced 2024-11-24 16:54:19 +00:00

Fix pineapple magnet

This commit is contained in:
Steffo 2023-01-08 10:20:01 +01:00
parent c9d4df4a86
commit 69384f9555
Signed by: steffo
GPG key ID: 6965406171929D01
3 changed files with 11 additions and 4 deletions

View file

@ -82,16 +82,20 @@ transform = Transform3D(1, 0, 0, 0, -0.337161, 0.941447, 0, -0.941447, -0.337161
[node name="Player" parent="." instance=ExtResource("3_5378m")] [node name="Player" parent="." instance=ExtResource("3_5378m")]
transform = Transform3D(-1, 3.48787e-16, -8.74228e-08, 3.48787e-16, 1, -3.48787e-16, 8.74228e-08, -3.48787e-16, -1, 0, 4.89631, 0) transform = Transform3D(-1, 3.48787e-16, -8.74228e-08, 3.48787e-16, 1, -3.48787e-16, 8.74228e-08, -3.48787e-16, -1, 0, 4.89631, 0)
[node name="CropTile" parent="." instance=ExtResource("8_4ooup")] [node name="CropTiles" type="Node3D" parent="."]
[node name="CropTile" parent="CropTiles" instance=ExtResource("8_4ooup")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1, 2, 8) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1, 2, 8)
debug_growth = true debug_growth = true
[node name="CropTile2" parent="." instance=ExtResource("8_4ooup")] [node name="CropTile2" parent="CropTiles" instance=ExtResource("8_4ooup")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 8) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 8)
debug_growth = true debug_growth = true
debug_growth_offset = 0.5 debug_growth_offset = 0.5
[node name="CropTile3" parent="." instance=ExtResource("8_4ooup")] [node name="CropTile3" parent="CropTiles" instance=ExtResource("8_4ooup")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 2, 8) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 2, 8)
debug_growth = true debug_growth = true
debug_growth_offset = 0.6 debug_growth_offset = 0.6
[node name="Produce" type="Node3D" parent="."]

View file

@ -13,6 +13,7 @@ radius = 3.0
[node name="Pineapple" type="RigidBody3D"] [node name="Pineapple" type="RigidBody3D"]
collision_layer = 2 collision_layer = 2
collision_mask = 3
lock_rotation = true lock_rotation = true
linear_damp = 1.0 linear_damp = 1.0

View file

@ -3,6 +3,7 @@ extends Node3D
@export var produce_scene: PackedScene = preload("res://island/Pineapple.tscn") @export var produce_scene: PackedScene = preload("res://island/Pineapple.tscn")
@onready var produce_container: Node3D = get_tree().root.find_child("Produce", true, false)
var rng: RandomNumberGenerator var rng: RandomNumberGenerator
@ -14,5 +15,6 @@ func _ready():
func produce_with_random_force(): func produce_with_random_force():
# TODO: Not sure it's a good idea attaching produce to the crop # TODO: Not sure it's a good idea attaching produce to the crop
var produce: RigidBody3D = produce_scene.instantiate() var produce: RigidBody3D = produce_scene.instantiate()
add_child(produce) produce.position = global_position
produce_container.add_child(produce)
produce.apply_impulse(Vector3.UP * rng.randf_range(15.0, 25.0)) produce.apply_impulse(Vector3.UP * rng.randf_range(15.0, 25.0))