From cf185592d6fe9d1b3736542f5f747c75534716d7 Mon Sep 17 00:00:00 2001 From: Rob Kelly Date: Thu, 9 Jan 2025 11:08:50 -0700 Subject: [PATCH] Terrain parameters includes bounce override --- levels/debug_level/terrain_assets.res | 4 ++-- src/equipment/balls/physics_ball/game_ball.gd | 3 +++ .../balls/physics_ball/normal_terrain_physics.tres | 10 ++++++++++ src/equipment/balls/physics_ball/physics_ball.tscn | 6 ++++-- .../physics_ball/terrain_physics/terrain_parameters.gd | 5 +++++ 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/levels/debug_level/terrain_assets.res b/levels/debug_level/terrain_assets.res index 85ba872..2f88b20 100644 --- a/levels/debug_level/terrain_assets.res +++ b/levels/debug_level/terrain_assets.res @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e300ec5067dd4ebe0c89e3834e1b9c1967847887bcde18d7ea3a7ff743e5864a -size 1660 +oid sha256:2355aa5e7b7322d88dc074ef9f9c5b1a5e64aaa050b92a90dbdde2d156e2beae +size 1748 diff --git a/src/equipment/balls/physics_ball/game_ball.gd b/src/equipment/balls/physics_ball/game_ball.gd index 32caacb..0154e11 100644 --- a/src/equipment/balls/physics_ball/game_ball.gd +++ b/src/equipment/balls/physics_ball/game_ball.gd @@ -153,6 +153,7 @@ func _integrate_forces(state: PhysicsDirectBodyState3D) -> void: _surface_time_s = 0.0 var params := terrain_physics.get_params(_surface_terrain) + #physics_material_override.bounce = params.bounce angular_damp = params.angular_damp linear_damp = params.linear_damp @@ -174,6 +175,8 @@ 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) diff --git a/src/equipment/balls/physics_ball/normal_terrain_physics.tres b/src/equipment/balls/physics_ball/normal_terrain_physics.tres index 8d86a6f..4de1c27 100644 --- a/src/equipment/balls/physics_ball/normal_terrain_physics.tres +++ b/src/equipment/balls/physics_ball/normal_terrain_physics.tres @@ -7,51 +7,61 @@ script = ExtResource("1_45pis") linear_damp = 1.15 angular_damp = 3.0 +bounce = 0.9 [sub_resource type="Resource" id="Resource_3k63c"] script = ExtResource("1_45pis") linear_damp = 0.0 angular_damp = 0.0 +bounce = 0.5 [sub_resource type="Resource" id="Resource_xf73q"] script = ExtResource("1_45pis") linear_damp = 4.4 angular_damp = 4.0 +bounce = 0.4 [sub_resource type="Resource" id="Resource_nhn3l"] script = ExtResource("1_45pis") linear_damp = 0.86 angular_damp = 1.0 +bounce = 0.9 [sub_resource type="Resource" id="Resource_m3wjo"] script = ExtResource("1_45pis") linear_damp = 2.3 angular_damp = 4.0 +bounce = 0.4 [sub_resource type="Resource" id="Resource_h4rld"] script = ExtResource("1_45pis") linear_damp = 1.62 angular_damp = 1.0 +bounce = 0.9 [sub_resource type="Resource" id="Resource_j6lib"] script = ExtResource("1_45pis") linear_damp = 4.7 angular_damp = 2.0 +bounce = 0.6 [sub_resource type="Resource" id="Resource_7f7ql"] script = ExtResource("1_45pis") linear_damp = 7.6 angular_damp = 4.0 +bounce = 0.3 [sub_resource type="Resource" id="Resource_pusmf"] script = ExtResource("1_45pis") linear_damp = 12.0 angular_damp = 32.0 +bounce = 0.0 [sub_resource type="Resource" id="Resource_edkxb"] script = ExtResource("1_45pis") linear_damp = 1.55 angular_damp = 1.3 +bounce = 0.8 [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 dee98c2..daf6859 100644 --- a/src/equipment/balls/physics_ball/physics_ball.tscn +++ b/src/equipment/balls/physics_ball/physics_ball.tscn @@ -1,7 +1,6 @@ [gd_scene load_steps=26 format=3 uid="uid://dfttci386ohip"] [ext_resource type="Script" path="res://src/equipment/balls/physics_ball/game_ball.gd" id="1_iwh2u"] -[ext_resource type="PhysicsMaterial" uid="uid://3bih72l068ic" path="res://src/equipment/balls/physics_ball/normal_physics.tres" id="1_l23pw"] [ext_resource type="Resource" uid="uid://c6tt1hto75ex4" path="res://src/equipment/balls/physics_ball/normal_terrain_physics.tres" id="3_3gnie"] [ext_resource type="Material" uid="uid://dpsmjlhjpc7vs" path="res://assets/materials/basic_ball_material.tres" id="3_rc7m1"] [ext_resource type="Script" path="res://src/equipment/balls/physics_ball/ball_sfx.gd" id="5_bhshl"] @@ -16,6 +15,9 @@ [ext_resource type="Texture2D" uid="uid://c47bkx508biqr" path="res://assets/sprites/particles/plasma.png" id="12_guipt"] [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 + [sub_resource type="SphereMesh" id="SphereMesh_y0d13"] material = ExtResource("3_rc7m1") radius = 0.05 @@ -132,7 +134,7 @@ size = Vector2(0.2, 0.2) [node name="PhysicsBall" type="RigidBody3D"] mass = 0.05 -physics_material_override = ExtResource("1_l23pw") +physics_material_override = SubResource("PhysicsMaterial_u134x") sleeping = true freeze = true continuous_cd = true 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 7ed1131..f10bf22 100644 --- a/src/equipment/balls/physics_ball/terrain_physics/terrain_parameters.gd +++ b/src/equipment/balls/physics_ball/terrain_physics/terrain_parameters.gd @@ -1,5 +1,10 @@ class_name TerrainParameters extends Resource ## Physical parameters for an individual terrain type. +## Linear damping applied while in contact with the terrain surface. @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