This commit is contained in:
Lucas 2025-03-21 17:43:59 +01:00
parent e651530751
commit cf76b1d256
No known key found for this signature in database
11 changed files with 173 additions and 1 deletions

40
boat/boat.gd Normal file
View file

@ -0,0 +1,40 @@
extends RigidBody3D
@export var float_force := 40
@export var water_drag := 0.05
@export var water_angular_drag := 0.05
@onready var gravity:float = ProjectSettings.get_setting("physics/3d/default_gravity")
const upforce_max := 500.0
const water_height :=0.0
var inWater := false
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func _physics_process(_delta: float) -> void:
var currentDepth = water_height - global_position.y
if currentDepth > 0:
inWater = true
var force_to_apply:Vector3 = Vector3.UP * clamp(float_force * gravity * currentDepth,0.0,upforce_max)
apply_central_force(force_to_apply)
else:
inWater = false
func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
# Change comportement based on if in water or not
if inWater:
state.linear_velocity *= 1 - water_drag
state.angular_velocity *= 1 - water_angular_drag

1
boat/boat.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://crtr3lle7lx7g

23
boat/boat.tscn Normal file
View file

@ -0,0 +1,23 @@
[gd_scene load_steps=4 format=3 uid="uid://babgqvkugifk1"]
[ext_resource type="Script" uid="uid://crtr3lle7lx7g" path="res://boat/boat.gd" id="1_jbc2f"]
[ext_resource type="PackedScene" uid="uid://bcdjvsj0la72h" path="res://boat/source/untitled.fbx" id="2_enlnh"]
[ext_resource type="Shape3D" uid="uid://jdtw7cqqrtpb" path="res://boat/model/Boat_CollisionShape.tres" id="3_ml88t"]
[node name="Boat" type="RigidBody3D"]
mass = 10.0
script = ExtResource("1_jbc2f")
[node name="SpringArm3D" type="SpringArm3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0.893285, 0.449491, 0, -0.449491, 0.893285, 0, 0.350159, 0)
spring_length = 2.255
[node name="Camera3D" type="Camera3D" parent="SpringArm3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.107117, 0.323316, 2.70191)
[node name="untitled" parent="." instance=ExtResource("2_enlnh")]
transform = Transform3D(-0.1, 0, -1.50996e-08, 0, 0.1, 0, 1.50996e-08, 0, -0.1, 0, -0.169637, 0)
[node name="BoatCollision" type="CollisionShape3D" parent="."]
transform = Transform3D(-10, 8.74228e-07, 3.82137e-14, 0, -4.37114e-07, 10, 8.74228e-07, 10, 4.37114e-07, -0.179, 0.151184, 0)
shape = ExtResource("3_ml88t")

BIN
boat/model.res Normal file

Binary file not shown.

File diff suppressed because one or more lines are too long

BIN
boat/ring.res Normal file

Binary file not shown.

BIN
boat/source/untitled.fbx Normal file

Binary file not shown.

View file

@ -0,0 +1,70 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://bcdjvsj0la72h"
path="res://.godot/imported/untitled.fbx-2cb6bc55ac8aef17b1fe3f0d79b293bf.scn"
[deps]
source_file="res://boat/source/untitled.fbx"
dest_files=["res://.godot/imported/untitled.fbx-2cb6bc55ac8aef17b1fe3f0d79b293bf.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=true
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
_subresources={
"meshes": {
"Mesh": {
"generate/lightmap_uv": 0,
"generate/lods": 0,
"generate/shadow_meshes": 0,
"lods/normal_merge_angle": 60.0,
"save_to_file/enabled": true,
"save_to_file/path": "res://boat/ring.res"
},
"Mesh_001": {
"generate/lightmap_uv": 0,
"generate/lods": 0,
"generate/shadow_meshes": 0,
"lods/normal_merge_angle": 60.0,
"save_to_file/enabled": true,
"save_to_file/path": "uid://b1pl5cswnak87"
},
"Mesh_016": {
"generate/lightmap_uv": 0,
"generate/lods": 0,
"generate/shadow_meshes": 0,
"lods/normal_merge_angle": 60.0,
"save_to_file/enabled": true,
"save_to_file/path": "res://boat/model.res"
}
},
"nodes": {
"PATH:Plane": {
"import/skip_import": true
}
}
}
fbx/importer=0
fbx/allow_geometry_helper_nodes=false
fbx/embedded_image_handling=1

BIN
boat/textures/Untitled.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 857 KiB

View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://scfxcj65nmxx"
path.s3tc="res://.godot/imported/Untitled.png-2e9d8314f2286b97d61a8694354e2606.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://boat/textures/Untitled.png"
dest_files=["res://.godot/imported/Untitled.png-2e9d8314f2286b97d61a8694354e2606.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
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

@ -24,7 +24,6 @@ void fragment() {
}
"
graph_offset = Vector2(-51.1487, -3.26273)
modes/diffuse = 3
modes/specular = 1
nodes/fragment/4/node = SubResource("VisualShaderNodeTexture_stlk6")