From 8280fdf4cded38565e949640630637d85a52e113 Mon Sep 17 00:00:00 2001 From: lucastucious Date: Thu, 3 Jul 2025 12:26:29 +0200 Subject: [PATCH] Add buoyancy force debug --- Boats/boat.tscn | 2 ++ Boats/buyancy_probe.gd | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Boats/boat.tscn b/Boats/boat.tscn index 9f9b539..a983cb5 100644 --- a/Boats/boat.tscn +++ b/Boats/boat.tscn @@ -24,6 +24,8 @@ size = Vector3(0.1, 2.5, 0.1) [node name="Boat" type="RigidBody3D"] mass = 50.0 +editor_description = "Base class for a floating boat" +can_sleep = false linear_damp_mode = 1 linear_damp = 0.8 angular_damp = 34.351 diff --git a/Boats/buyancy_probe.gd b/Boats/buyancy_probe.gd index bf990d6..f7d4c47 100644 --- a/Boats/buyancy_probe.gd +++ b/Boats/buyancy_probe.gd @@ -18,6 +18,7 @@ var currentdepth:float var sphere_preview:MeshInstance3D @onready var debug_sphere:SphereMesh = SphereMesh.new() +@onready var debug_label:Label3D = Label3D.new() @export_category("Wave") var noise: Image @@ -47,6 +48,16 @@ func _ready() -> void: debug_sphere.radius = 0.1 debug_sphere.height = 0.2 sphere_preview.mesh = debug_sphere + if debug: + debug_label.billboard = 1 + debug_label.outline_render_priority = 98 + debug_label.render_priority = 99 + debug_label.pixel_size = 0.005 + debug_label.horizontal_alignment = 0 + debug_label.no_depth_test = true + debug_label.font_size = 50 + add_child(debug_label) + func _physics_process(_delta: float) -> void: if not Engine.is_editor_hint(): @@ -56,9 +67,14 @@ func _physics_process(_delta: float) -> void: var float_force = parentRigid.mass * float_strength #parentRigid.gravity_scale = 0.3 #parentRigid.angular_damp = 15.0 - parentRigid.apply_force(Vector3.UP * clamp(gravity * depth * float_force,-max_float_force,max_float_force) ,global_position-parentRigid.global_position) + var applied_force : Vector3 = Vector3.UP * clamp(gravity * depth * float_force,-max_float_force,max_float_force) + parentRigid.apply_force(applied_force,global_position-parentRigid.global_position) if debug: - print(str(self)+" is applying a force of "+str(Vector3.UP * clamp(gravity * depth * float_force,-max_float_force,max_float_force) ,global_position-parentRigid.global_position)+"to "+str(parentRigid)) + #print(str(self)+" is applying a force of "+str(applied_force)+" at "+str(global_position-parentRigid.global_position)+" to "+str(parentRigid)) + debug_label.text = str(snappedf(applied_force.y,0.01)) + debug_label.global_position = global_position + debug_label.global_position.y = get_wave_height(global_position,Oceantime)+0.3 + func _process(_delta: float) -> void: if OceanNode != null: