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

Create floating pineapple

Not too happy with the physics so far but it's ok
This commit is contained in:
Steffo 2023-01-08 09:22:44 +01:00
parent a073bc4e73
commit 1cb3a8f37f
Signed by: steffo
GPG key ID: 6965406171929D01
11 changed files with 178 additions and 1 deletions

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,9 @@
newmtl material2
Ka 1.000000 1.000000 1.000000
Kd 1.000000 1.000000 1.000000
Ks 0.000000 0.000000 0.000000
Tr 0.000000
illum 0
Ns 0.000000
map_Kd texture_2.png
map_d texture_2.png

BIN
assets/island_model/pineapple.obj (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,21 @@
[remap]
importer="wavefront_obj"
importer_version=1
type="Mesh"
uid="uid://dfsr4x88l1l2r"
path="res://.godot/imported/pineapple.obj-f022637733323e5da85a7579b2bebb0e.mesh"
[deps]
files=["res://.godot/imported/pineapple.obj-f022637733323e5da85a7579b2bebb0e.mesh"]
source_file="res://assets/island_model/pineapple.obj"
dest_files=["res://.godot/imported/pineapple.obj-f022637733323e5da85a7579b2bebb0e.mesh", "res://.godot/imported/pineapple.obj-f022637733323e5da85a7579b2bebb0e.mesh"]
[params]
generate_tangents=true
scale_mesh=Vector3(1, 1, 1)
offset_mesh=Vector3(0, 0, 0)
optimize_mesh=true

BIN
assets/island_model/texture_2.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cukw0nvmbodxq"
path="res://.godot/imported/texture_2.png-3fec962867bbfafd5a9fea7753401573.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/island_model/texture_2.png"
dest_files=["res://.godot/imported/texture_2.png-3fec962867bbfafd5a9fea7753401573.ctex"]
[params]
compress/mode=3
compress/lossy_quality=0.0
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=false
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=15 format=3 uid="uid://bg88gc1w1gw5m"]
[gd_scene load_steps=16 format=3 uid="uid://bg88gc1w1gw5m"]
[ext_resource type="Shader" path="res://island/Sea.gdshader" id="1_agjfy"]
[ext_resource type="Texture2D" uid="uid://bdoifsf6k0qb8" path="res://assets/water_tile.png" id="1_w6ara"]
@ -9,6 +9,7 @@
[ext_resource type="PackedScene" uid="uid://bknwefv5ycc3u" path="res://island/PyramidSmolMesh.tscn" id="6_klmt8"]
[ext_resource type="PackedScene" uid="uid://boxtb3trgcy8c" path="res://island/PillarMesh.tscn" id="7_grmwj"]
[ext_resource type="PackedScene" uid="uid://cf35yl04qtru3" path="res://island/CropTile.tscn" id="8_4ooup"]
[ext_resource type="PackedScene" uid="uid://v7bv81krh12e" path="res://island/Pineapple.tscn" id="10_cvxfg"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_3uyyi"]
render_priority = 0
@ -95,3 +96,8 @@ debug_growth_offset = 0.5
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 2, 8)
debug_growth = true
debug_growth_offset = 0.6
[node name="Pineapple" parent="." instance=ExtResource("10_cvxfg")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4, 3, 31)
[editable path="Pineapple"]

View file

@ -0,0 +1,29 @@
extends Node
@export var force_multiplier: float = 0.0
# Must be BELOW the player node to work!
@onready var parent: RigidBody3D = get_parent()
@onready var magnet_area: Area3D = $MagnetArea
@onready var player: CharacterBody3D = get_tree().root.find_child("Player", true, false)
var captured = false
func capture():
captured = true
func _physics_process(delta):
if captured:
var direction = player.position - parent.position
var force = direction.normalized() * force_multiplier * delta
force.y = abs(force.y)
parent.apply_force(force)
func _on_magnet_area_body_entered(body: Node3D):
if body.name == "Player":
print("Player captured pickup!")
capture()

37
island/Pineapple.tscn Normal file
View file

@ -0,0 +1,37 @@
[gd_scene load_steps=5 format=3 uid="uid://v7bv81krh12e"]
[ext_resource type="PackedScene" uid="uid://bwwpi0itor6cw" path="res://island/PineappleMesh.tscn" id="1_ndmmp"]
[ext_resource type="Script" path="res://island/MoveTowardsPlayer.gd" id="2_d3itl"]
[sub_resource type="CylinderShape3D" id="CylinderShape3D_t5bjw"]
height = 0.9
radius = 0.3
[sub_resource type="CylinderShape3D" id="CylinderShape3D_m5gp0"]
height = 6.0
radius = 3.0
[node name="Pineapple" type="RigidBody3D"]
collision_layer = 2
lock_rotation = true
linear_damp = 3.0
[node name="Shape" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.45, 0)
shape = SubResource("CylinderShape3D_t5bjw")
[node name="PineappleMesh" parent="." instance=ExtResource("1_ndmmp")]
[node name="MoveTowardsPlayer" type="Node3D" parent="."]
script = ExtResource("2_d3itl")
force_multiplier = 1250.0
[node name="MagnetArea" type="Area3D" parent="MoveTowardsPlayer"]
collision_layer = 0
monitorable = false
[node name="Shape" type="CollisionShape3D" parent="MoveTowardsPlayer/MagnetArea"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
shape = SubResource("CylinderShape3D_m5gp0")
[connection signal="body_entered" from="MoveTowardsPlayer/MagnetArea" to="MoveTowardsPlayer" method="_on_magnet_area_body_entered"]

29
island/PineappleMesh.tscn Normal file
View file

@ -0,0 +1,29 @@
[gd_scene load_steps=4 format=3 uid="uid://bwwpi0itor6cw"]
[ext_resource type="Texture2D" uid="uid://cukw0nvmbodxq" path="res://assets/island_model/texture_2.png" id="1_x2h5q"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_8u420"]
resource_name = "material2"
transparency = 1
shading_mode = 0
albedo_texture = ExtResource("1_x2h5q")
texture_filter = 0
billboard_mode = 1
[sub_resource type="ArrayMesh" id="ArrayMesh_sjes8"]
_surfaces = [{
"aabb": AABB(-0.5, 0, 0, 1.00001, 1.00001, 1e-05),
"attribute_data": PackedByteArray(40, 175, 161, 62, 0, 0, 0, 0, 229, 53, 148, 62, 172, 170, 42, 62, 229, 53, 148, 62, 0, 0, 0, 0, 40, 175, 161, 62, 172, 170, 42, 62),
"format": 4119,
"index_count": 6,
"index_data": PackedByteArray(0, 0, 1, 0, 2, 0, 3, 0, 1, 0, 0, 0),
"material": SubResource("StandardMaterial3D_8u420"),
"name": "material2",
"primitive": 3,
"vertex_count": 4,
"vertex_data": PackedByteArray(0, 0, 0, 63, 0, 0, 128, 63, 0, 0, 0, 0, 255, 127, 255, 127, 255, 255, 255, 191, 0, 0, 0, 191, 0, 0, 0, 0, 0, 0, 0, 0, 255, 127, 255, 127, 255, 255, 255, 191, 0, 0, 0, 191, 0, 0, 128, 63, 0, 0, 0, 0, 255, 127, 255, 127, 255, 255, 255, 191, 0, 0, 0, 63, 0, 0, 0, 0, 0, 0, 0, 0, 255, 127, 255, 127, 255, 255, 255, 191)
}]
[node name="PineappleMesh" type="MeshInstance3D"]
mesh = SubResource("ArrayMesh_sjes8")
skeleton = NodePath("../..")

View file

@ -108,6 +108,11 @@ fire={
]
}
[layer_names]
3d_physics/layer_1="Default"
3d_physics/layer_2="Pickups"
[rendering]
renderer/rendering_method="gl_compatibility"