diff --git a/src/equipment/balls/physics_ball/game_ball.gd b/src/equipment/balls/physics_ball/game_ball.gd index 0154e11..b2bbbb2 100644 --- a/src/equipment/balls/physics_ball/game_ball.gd +++ b/src/equipment/balls/physics_ball/game_ball.gd @@ -133,13 +133,14 @@ func _integrate_forces(state: PhysicsDirectBodyState3D) -> void: _surface_time_s = 0.0 # TODO something's fucky here... I think this gets called once after the ball sleeps - if state.get_contact_count(): + var contacts := state.get_contact_count() + if contacts: # Ball is in contact with a surface # We want the contact normal which minimizes the angle to the up vector - var min_dot := -1.0 + var min_dot := -2.0 var primary_body: Node - for i: int in range(state.get_contact_count()): + for i: int in range(contacts): var norm := state.get_contact_local_normal(i) var dot := norm.dot(Vector3.UP) if dot > min_dot: @@ -175,8 +176,6 @@ func _physics_process(delta: float) -> void: _shot_time_s += delta _surface_time_s += delta - physics_material_override.bounce = terrain_physics.get_params(_surface_terrain).bounce - func enter_zone(zone: BallZone) -> void: _zones.push_back(zone) @@ -225,6 +224,8 @@ func _on_collision(body: Node) -> void: sfx.play_sfx(terrain) effects.play_effect(terrain) + linear_velocity *= clampf(1 - terrain_physics.get_params(terrain).impact_damp, 0, 1) + func _fire_sleep_signal() -> void: sleeping = true diff --git a/src/equipment/balls/physics_ball/normal_terrain_physics.tres b/src/equipment/balls/physics_ball/normal_terrain_physics.tres index 4de1c27..6c5698c 100644 --- a/src/equipment/balls/physics_ball/normal_terrain_physics.tres +++ b/src/equipment/balls/physics_ball/normal_terrain_physics.tres @@ -5,63 +5,63 @@ [sub_resource type="Resource" id="Resource_casfi"] script = ExtResource("1_45pis") -linear_damp = 1.15 +linear_damp = 1.05 angular_damp = 3.0 -bounce = 0.9 +impact_damp = 0.05 [sub_resource type="Resource" id="Resource_3k63c"] script = ExtResource("1_45pis") linear_damp = 0.0 angular_damp = 0.0 -bounce = 0.5 +impact_damp = 0.0 [sub_resource type="Resource" id="Resource_xf73q"] script = ExtResource("1_45pis") -linear_damp = 4.4 +linear_damp = 2.8 angular_damp = 4.0 -bounce = 0.4 +impact_damp = 0.3 [sub_resource type="Resource" id="Resource_nhn3l"] script = ExtResource("1_45pis") linear_damp = 0.86 angular_damp = 1.0 -bounce = 0.9 +impact_damp = 0.0 [sub_resource type="Resource" id="Resource_m3wjo"] script = ExtResource("1_45pis") -linear_damp = 2.3 +linear_damp = 1.25 angular_damp = 4.0 -bounce = 0.4 +impact_damp = 0.3 [sub_resource type="Resource" id="Resource_h4rld"] script = ExtResource("1_45pis") linear_damp = 1.62 angular_damp = 1.0 -bounce = 0.9 +impact_damp = 0.0 [sub_resource type="Resource" id="Resource_j6lib"] script = ExtResource("1_45pis") -linear_damp = 4.7 +linear_damp = 4.0 angular_damp = 2.0 -bounce = 0.6 +impact_damp = 0.15 [sub_resource type="Resource" id="Resource_7f7ql"] script = ExtResource("1_45pis") -linear_damp = 7.6 -angular_damp = 4.0 -bounce = 0.3 +linear_damp = 3.0 +angular_damp = 8.0 +impact_damp = 0.5 [sub_resource type="Resource" id="Resource_pusmf"] script = ExtResource("1_45pis") -linear_damp = 12.0 -angular_damp = 32.0 -bounce = 0.0 +linear_damp = 4.0 +angular_damp = 4.0 +impact_damp = 0.7 [sub_resource type="Resource" id="Resource_edkxb"] script = ExtResource("1_45pis") -linear_damp = 1.55 +linear_damp = 1.25 angular_damp = 1.3 -bounce = 0.8 +impact_damp = 0.15 [resource] script = ExtResource("2_yuehx") diff --git a/src/equipment/balls/physics_ball/physics_ball.tscn b/src/equipment/balls/physics_ball/physics_ball.tscn index daf6859..2bf07b2 100644 --- a/src/equipment/balls/physics_ball/physics_ball.tscn +++ b/src/equipment/balls/physics_ball/physics_ball.tscn @@ -16,7 +16,7 @@ [ext_resource type="PackedScene" uid="uid://cm4bb3lg4mfd2" path="res://src/world/effects/splash/splash_effect.tscn" id="12_qlrvx"] [sub_resource type="PhysicsMaterial" id="PhysicsMaterial_u134x"] -bounce = 0.4 +bounce = 0.8 [sub_resource type="SphereMesh" id="SphereMesh_y0d13"] material = ExtResource("3_rc7m1") diff --git a/src/equipment/balls/physics_ball/terrain_physics/terrain_parameters.gd b/src/equipment/balls/physics_ball/terrain_physics/terrain_parameters.gd index f10bf22..afc9bd9 100644 --- a/src/equipment/balls/physics_ball/terrain_physics/terrain_parameters.gd +++ b/src/equipment/balls/physics_ball/terrain_physics/terrain_parameters.gd @@ -5,6 +5,6 @@ class_name TerrainParameters extends Resource @export var linear_damp := 0.0 ## Angular damping applied while in contact with the terrain surface. @export var angular_damp := 0.0 - -## Physical bounciness of the terrain. Use this instead of the physics material override. -@export var bounce := 0.0 +## Linear damping applied the frame the ball makes contact with the surface. +## This is applied in addition `linear_damp`. +@export var impact_damp := 0.0