various fixes

This commit is contained in:
bee
2026-07-09 08:18:48 +02:00
parent c4f2c0a202
commit e78d11998f
10 changed files with 33 additions and 25 deletions
+3 -3
View File
@@ -1,7 +1,7 @@
TODO:
DONE Controller/possession refactor (input out of Boat).
WeaponDef resource + WeaponSlot + one dumb gun that prints instead of shooting.
Projectile base (with group self-registration) + real firing.
Loadout-driven mounting.
DONE WeaponDef resource + WeaponSlot + one dumb gun that prints instead of shooting.
DONE Projectile base (with group self-registration) + real firing.
DONE Loadout-driven mounting.
Second boat scene to prove the whole seam.
-1
View File
@@ -74,4 +74,3 @@ current_controlled = NodePath("../Boat")
world_manager = NodePath("../WorldManager")
camera_rig = NodePath("../CameraRig")
hud = NodePath("../Hud")
throttle_ramp = null
-6
View File
@@ -3,14 +3,8 @@
[ext_resource type="Material" uid="uid://6p5bg1nyso6d" path="res://materials/stylized_water.tres" id="1_j38dg"]
[ext_resource type="Script" uid="uid://co5xetl8amg4j" path="res://scripts/ocean.gd" id="2_nb2vx"]
[sub_resource type="PlaneMesh" id="PlaneMesh_ocean"]
size = Vector2(200, 200)
subdivide_width = 200
subdivide_depth = 200
[node name="Ocean" type="MeshInstance3D" unique_id=521355215 groups=["follow_focus", "ocean"]]
material_override = ExtResource("1_j38dg")
mesh = SubResource("PlaneMesh_ocean")
script = ExtResource("2_nb2vx")
sea_height = 1.0
sea_choppy = 8.0
+1 -1
View File
@@ -30,4 +30,4 @@ func _unhandled_input(event: InputEvent) -> void:
func _process(delta: float) -> void:
if target:
global_position = global_position.lerp(target.global_position, follow_speed * delta)
global_position = global_position.lerp(target.global_position, 1.0 - exp(-follow_speed * delta))
+4 -3
View File
@@ -24,7 +24,6 @@ extends RigidBody3D
var _probe_offsets: Array[Vector3] = [] # local space
var _ocean: Ocean
# var _probes: Array[Marker3D] = [] TODO: Probably unused
var _gravity: float = ProjectSettings.get_setting("physics/3d/default_gravity")
var submerged_ratio := 0.0
@@ -39,10 +38,12 @@ func _ready() -> void:
if _probe_offsets.is_empty():
for col in probe_grid.x:
for row in probe_grid.y:
var tx := 0.5 if probe_grid.x <= 1 else col / float(probe_grid.x - 1)
var tz := 0.5 if probe_grid.y <= 1 else row / float(probe_grid.y - 1)
_probe_offsets.append(Vector3(
lerpf(-probe_extents.x, probe_extents.x, col / float(probe_grid.x - 1)),
lerpf(-probe_extents.x, probe_extents.x, tx),
probe_extents.y,
lerpf(-probe_extents.z, probe_extents.z, row / float(probe_grid.y - 1))))
lerpf(-probe_extents.z, probe_extents.z, tz)))
+9 -4
View File
@@ -30,16 +30,21 @@ extends MeshInstance3D
set(value):
iter_geometry = value
_push("ITER_GEOMETRY", value)
## Node the ocean mesh stays centered under (camera rig or boat).
## Half-size of the rendered ocean square, in meters.
## Half-size of the rendered ocean square, in meters
@export var render_distance := 100.0:
set(value):
render_distance = value
if is_node_ready():
_rebuild_mesh()
## World-space distance between mesh vertices; smaller = more wave detail.
@export var vertex_spacing := 1.0
## World-space distance between mesh vertices; smaller = more wave detail.
@export var vertex_spacing := 1.0:
set(value):
vertex_spacing = value
if is_node_ready():
_rebuild_mesh()
var _phase := 0.0
var _wave_offset := Vector2.ZERO
+9 -3
View File
@@ -3,6 +3,9 @@ extends Node
@export var current_controlled : Boat:
set(value):
if current_controlled != null and current_controlled != value:
current_controlled.desired_throttle = 0.0
current_controlled.steer_input = 0.0
current_controlled = value
if is_node_ready():
if current_controlled != null:
@@ -57,6 +60,9 @@ func _process(delta: float) -> void:
current_controlled.fire_weapons()
func _possess() -> void:
camera_rig.target = current_controlled
world_manager.focus = current_controlled
hud.boat = current_controlled
if camera_rig != null:
camera_rig.target = current_controlled
if world_manager != null:
world_manager.focus = current_controlled
if hud != null:
hud.boat = current_controlled
+1 -1
View File
@@ -18,7 +18,7 @@ func launch(def: AmmoDef, muzzle: Transform3D, speed_scale := 1.0) -> void:
reset_physics_interpolation()
func _physics_process(delta: float) -> void:
if Vector3.UP.cross(linear_velocity).length_squared() > 0.01:
if linear_velocity.length_squared() > 0.01 and absf(linear_velocity.normalized().dot(Vector3.UP)) < 0.999:
look_at(global_position + linear_velocity)
_time_left -= delta
+2 -3
View File
@@ -1,8 +1,7 @@
extends Label
@export var boat: Boat
@export var world: WorldManager
var boat: Boat # Assigned by hud
var world: WorldManager # Assigned by hud
func _process(_delta: float) -> void:
if boat == null or world == null:
+4
View File
@@ -12,6 +12,10 @@ func can_mount(def: WeaponDef) -> bool:
func mount(def: WeaponDef) -> bool:
if not can_mount(def):
push_warning("%s can't mount %s" % [
name,
def.display_name if def != null else "<null def>"
])
return false
unmount()
weapon = def.weapon_scene.instantiate()