Feat/3 adding playermodel #8

Merged
Dotts merged 7 commits from feat/3-adding-playermodel into main 2026-06-05 21:23:53 -07:00
2 changed files with 13 additions and 5 deletions
Showing only changes of commit cb5708e19e - Show all commits
+9 -3
View File
@@ -85,9 +85,14 @@ func _die(_hit_position: Vector3, source: Node, damage_amount: float) -> void:
ragdoll_instance.build_ragdoll(Color(0.8, 0.5, 0.1))
# Calculate impulse
var linear_vel = Vector3.ZERO
var impulse = Vector3.ZERO
if pending_impulse.length_squared() > 0.01:
impulse = pending_impulse
# The player treats incoming impulses as direct velocity additions (v += impulse)
# To make the dummy fly exactly like the player, we must use it as base linear velocity!
linear_vel = pending_impulse
impulse = pending_impulse * 0.5
pending_impulse = Vector3.ZERO
else:
var hit_dir = Vector3.BACK
@@ -98,11 +103,12 @@ func _die(_hit_position: Vector3, source: Node, damage_amount: float) -> void:
if cam:
hit_dir = (_hit_position - cam.global_position).normalized()
impulse = hit_dir * (damage_amount * 0.5)
linear_vel = hit_dir * (damage_amount * 0.05)
impulse = hit_dir * (damage_amount * 1.5)
get_tree().create_timer(0.01).timeout.connect(func():
if is_instance_valid(ragdoll_instance):
ragdoll_instance.apply_initial_velocities(Vector3.ZERO, impulse)
ragdoll_instance.apply_initial_velocities(linear_vel, impulse)
)
get_tree().create_timer(3.0).timeout.connect(func():
+4 -2
View File
@@ -193,9 +193,11 @@ func _shoot_hitscan() -> void:
var falloff_factor = clampf((hit_dist - falloff_start) / (max_range - falloff_start), 0.0, 1.0)
damage = lerpf(base_dmg, min_dmg, falloff_factor)
if result.collider.has_method("apply_impulse"):
result.collider.apply_impulse(pellet_dir * 8.0) # Apply strong physical force for ragdoll
if result.collider.has_method("take_damage"):
var hit_impulse = pellet_dir * 8.0 # Apply strong physical force for ragdoll
result.collider.take_damage(damage, result.position, player, hit_impulse)
result.collider.take_damage(damage, result.position, player)
else:
ImpactSpawner.spawn(get_tree(), "bullet", result.position, result.normal, 0.08)