diff --git a/src/equipment/balls/brick/brick.tscn b/src/equipment/balls/brick/brick.tscn index cd7b4a9..2af7238 100644 --- a/src/equipment/balls/brick/brick.tscn +++ b/src/equipment/balls/brick/brick.tscn @@ -14,6 +14,7 @@ size = Vector3(0.147, 0.092, 0.31) [node name="Brick" instance=ExtResource("1_y1dte")] mass = 0.08 physics_material_override = SubResource("PhysicsMaterial_f03f4") +radius = 0.15 [node name="BrickMesh" parent="." index="0" instance=ExtResource("2_ubuxr")] transform = Transform3D(0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, 0, 0) diff --git a/src/equipment/balls/physics_ball/game_ball.gd b/src/equipment/balls/physics_ball/game_ball.gd index 6a74014..52ed1f6 100644 --- a/src/equipment/balls/physics_ball/game_ball.gd +++ b/src/equipment/balls/physics_ball/game_ball.gd @@ -39,6 +39,9 @@ const MAGNUS_EPSILON := 1e-3 ## Scaling factor for additional force-based damage @export var damage_force_scale := 0.01 +## Approximate average radius, for physics purposes +@export var radius := 0.05 + var current_gravity: Vector3 var _last_contact_normal: Vector3 = Vector3.UP diff --git a/src/player/shot_setup/shot_setup.gd b/src/player/shot_setup/shot_setup.gd index d924a29..89b2bdb 100644 --- a/src/player/shot_setup/shot_setup.gd +++ b/src/player/shot_setup/shot_setup.gd @@ -39,6 +39,9 @@ const WATER_DAMAGE := 10.0 ## Angle of influence that shot curve has, in radians const CURVE_INFLUENCE := PI / 16 +## Just enough to make things interesting! +const SHOT_OFFSET_Z_FACTOR := 2.0 / 45.0 + ## Impulse offset multiplier due to curve, in meters const CURVE_FACTOR := 0.002 @@ -262,10 +265,16 @@ func take_shot() -> void: print_debug("Shot impulse: ", impulse, "; ", impulse.length(), " N*s") # Curve the curve - var curve := direction.global_basis.x.normalized() * shot_curve * absf(shot_curve) + var curve := shot_curve * absf(shot_curve) * CURVE_FACTOR # Position where the ball is hit (imparts spin) - var offset := -curve * CURVE_FACTOR + var offset := direction.global_basis.x.normalized() * -curve + offset += ( + direction.global_basis.z.normalized() + * game_ball.radius + * game_ball.radius + * SHOT_OFFSET_Z_FACTOR + ) print_debug("Shot offset: ", offset, "; ", offset.length(), " m") if game_ball: