Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Code/Game/Weapon/BaseCarryable/BaseCarryable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,13 @@ public void TraceAttack( TraceAttackInfo attack )
if ( !attack.Target.IsValid() )
return;

// Impact before the damage, so the prop gets the impulse and can pass it down to gibs.
if ( attack.Target.GetComponentInChildren<Rigidbody>() is var rb && rb.IsValid() )
{
// TODO: Scale this based on damage?
rb.ApplyImpulseAt( attack.Position, Vector3.Direction( attack.Origin, attack.Position ) * rb.Mass * 100 );
Comment thread
Xenthio marked this conversation as resolved.
}
Comment thread
Xenthio marked this conversation as resolved.

// Use owner as attacker when held by a player, seated player when controlled from a
// contraption seat, or fall back to the weapon itself (standalone/world weapon)
var attacker = EffectiveAttacker;
Expand All @@ -335,12 +342,6 @@ public void TraceAttack( TraceAttackInfo attack )

dmg.OnDamage( info );
}

if ( attack.Target.GetComponentInChildren<Rigidbody>() is var rb && rb.IsValid() )
{
// TODO: Scale this based on damage?
rb.ApplyImpulseAt( attack.Position, Vector3.Direction( attack.Origin, attack.Position ) * rb.Mass * 100 );
}
}

/// <summary>
Expand Down