mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-14 16:42:08 +00:00
feat(*): add wall/ceiling surface pull and retune ball-ship materials
This commit is contained in:
@@ -19,6 +19,12 @@ extends RigidBody3D
|
||||
@export var drag_coefficient = 0.98 # Linear drag (air resistance)
|
||||
@export var angular_drag = 0.95 # Rotational drag
|
||||
|
||||
@export_group("Surface Pull")
|
||||
@export var wall_pull_strength = 6.0 # Wall grav-plating strength (m/s^2-equivalent)
|
||||
@export var wall_pull_range = 3.0 # Metres from a wall where pull begins
|
||||
@export var ceiling_pull_strength = 11.5 # Ceiling grav-plating strength; nets above gravity so a ship can hold a ceiling
|
||||
@export var ceiling_pull_range = 3.0 # Metres from the ceiling where pull begins
|
||||
|
||||
# Accent colours per team, applied to the nose and tail fin meshes so the
|
||||
# two sides are tellable apart at a glance.
|
||||
const TEAM_COLORS := {
|
||||
@@ -34,6 +40,7 @@ var team: int = 0:
|
||||
|
||||
var controller: ShipController
|
||||
var _current_action: ShipAction = ShipAction.new()
|
||||
var _boundary: ArenaBoundary
|
||||
|
||||
# Instrument signals for efficient data distribution
|
||||
signal speed_changed(speed: float)
|
||||
@@ -74,6 +81,8 @@ func _ready():
|
||||
|
||||
_apply_team_color()
|
||||
|
||||
_boundary = get_tree().get_first_node_in_group("arena_boundary")
|
||||
|
||||
|
||||
func _apply_team_color() -> void:
|
||||
if not is_inside_tree():
|
||||
@@ -112,6 +121,7 @@ func _integrate_forces(state):
|
||||
|
||||
# === TRANSLATION (Movement) ===
|
||||
apply_thruster_forces(state, _current_action)
|
||||
apply_surface_pull(state)
|
||||
|
||||
# === ROTATION (Turning) ===
|
||||
apply_rotation_forces(state, _current_action.rotation)
|
||||
@@ -153,6 +163,16 @@ func apply_thruster_forces(state: PhysicsDirectBodyState3D, action: ShipAction):
|
||||
state.apply_central_force(world_thrust)
|
||||
|
||||
|
||||
func apply_surface_pull(state: PhysicsDirectBodyState3D) -> void:
|
||||
if _boundary == null:
|
||||
return
|
||||
var pull := _boundary.get_surface_pull(
|
||||
global_position, wall_pull_strength, wall_pull_range,
|
||||
ceiling_pull_strength, ceiling_pull_range
|
||||
)
|
||||
state.apply_central_force(pull * mass)
|
||||
|
||||
|
||||
func apply_rotation_forces(state: PhysicsDirectBodyState3D, rotation_input: Vector3):
|
||||
if rotation_input.length() < 0.01:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user