generated from krampus/template-godot4
Tweaked magnus force to not affect good shots as much
This commit is contained in:
parent
9b9979e8ac
commit
424ee2f2ae
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue