Feat/3 adding playermodel #8
@@ -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))
|
ragdoll_instance.build_ragdoll(Color(0.8, 0.5, 0.1))
|
||||||
|
|
||||||
# Calculate impulse
|
# Calculate impulse
|
||||||
|
var linear_vel = Vector3.ZERO
|
||||||
var impulse = Vector3.ZERO
|
var impulse = Vector3.ZERO
|
||||||
|
|
||||||
if pending_impulse.length_squared() > 0.01:
|
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
|
pending_impulse = Vector3.ZERO
|
||||||
else:
|
else:
|
||||||
var hit_dir = Vector3.BACK
|
var hit_dir = Vector3.BACK
|
||||||
@@ -98,11 +103,12 @@ func _die(_hit_position: Vector3, source: Node, damage_amount: float) -> void:
|
|||||||
if cam:
|
if cam:
|
||||||
hit_dir = (_hit_position - cam.global_position).normalized()
|
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():
|
get_tree().create_timer(0.01).timeout.connect(func():
|
||||||
if is_instance_valid(ragdoll_instance):
|
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():
|
get_tree().create_timer(3.0).timeout.connect(func():
|
||||||
|
|||||||
@@ -193,9 +193,11 @@ func _shoot_hitscan() -> void:
|
|||||||
var falloff_factor = clampf((hit_dist - falloff_start) / (max_range - falloff_start), 0.0, 1.0)
|
var falloff_factor = clampf((hit_dist - falloff_start) / (max_range - falloff_start), 0.0, 1.0)
|
||||||
damage = lerpf(base_dmg, min_dmg, falloff_factor)
|
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"):
|
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)
|
||||||
result.collider.take_damage(damage, result.position, player, hit_impulse)
|
|
||||||
else:
|
else:
|
||||||
ImpactSpawner.spawn(get_tree(), "bullet", result.position, result.normal, 0.08)
|
ImpactSpawner.spawn(get_tree(), "bullet", result.position, result.normal, 0.08)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user